﻿
// This file implements the TableControl, TableControlRow, and RecordControl classes for the 
// ShowBugsSummaryTablePage.aspx page.  The Row or RecordControl classes are the 
// ideal place to add code customizations. For example, you can override the LoadData, 
// CreateWhereClause, DataBind, SaveData, GetUIData, and Validate methods.

#region "Using statements"    

using Microsoft.VisualBasic;
using BaseClasses.Web.UI.WebControls;
using System;
using System.Collections;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BaseClasses;
using BaseClasses.Data;
using BaseClasses.Utils;

using ReportTools.ReportCreator;
using ReportTools.Shared;

using BUGLOG.Business;
using BUGLOG.Data;
        

#endregion

  
namespace BUGLOG.UI.Controls.ShowBugsSummaryTablePage
{
  

#region "Section 1: Place your customizations here."

    
//public class BugsSummaryTableControlRow : BaseBugsSummaryTableControlRow
//{
//      
//        // The BaseBugsSummaryTableControlRow implements code for a ROW within the
//        // the BugsSummaryTableControl table.  The BaseBugsSummaryTableControlRow implements the DataBind and SaveData methods.
//        // The loading of data is actually performed by the LoadData method in the base class of BugsSummaryTableControl.
//
//        // This is the ideal place to add your code customizations. For example, you can override the DataBind, 
//        // SaveData, GetUIData, and Validate methods.
//        
//
//}
//

  

//public class BugsSummaryTableControl : BaseBugsSummaryTableControl
//{
//        // The BaseBugsSummaryTableControl class implements the LoadData, DataBind, CreateWhereClause
//        // and other methods to load and display the data in a table control.
//
//        // This is the ideal place to add your code customizations. You can override the LoadData and CreateWhereClause,
//        // The BugsSummaryTableControlRow class offers another place where you can customize
//        // the DataBind, GetUIData, SaveData and Validate methods specific to each row displayed on the table.
//
//}
//

  

public class BugsSummaryTableControl1 : BaseBugsSummaryTableControl1
{
        // The BaseBugsSummaryTableControl1 class implements the LoadData, DataBind, CreateWhereClause
        // and other methods to load and display the data in a table control.

        // This is the ideal place to add your code customizations. You can override the LoadData and CreateWhereClause,
        // The BugsSummaryTableControl1Row class offers another place where you can customize
        // the DataBind, GetUIData, SaveData and Validate methods specific to each row displayed on the table.

}
public class BugsSummaryTableControl1Row : BaseBugsSummaryTableControl1Row
{
      
        // The BaseBugsSummaryTableControl1Row implements code for a ROW within the
        // the BugsSummaryTableControl1 table.  The BaseBugsSummaryTableControl1Row implements the DataBind and SaveData methods.
        // The loading of data is actually performed by the LoadData method in the base class of BugsSummaryTableControl1.

        // This is the ideal place to add your code customizations. For example, you can override the DataBind, 
        // SaveData, GetUIData, and Validate methods.
        

}
#endregion

  

#region "Section 2: Do not modify this section."
    
    
// Base class for the BugsSummaryTableControl1Row control on the ShowBugsSummaryTablePage page.
// Do not modify this class. Instead override any method in BugsSummaryTableControl1Row.
public class BaseBugsSummaryTableControl1Row : BUGLOG.UI.BaseApplicationRecordControl
{
        public BaseBugsSummaryTableControl1Row()
        {
            this.Init += new EventHandler(Control_Init);
            this.Load += new EventHandler(Control_Load);
            this.PreRender += new EventHandler(Control_PreRender);
        }

        // To customize, override this method in BugsSummaryTableControl1Row.
        protected virtual void Control_Init(object sender, System.EventArgs e)
        {
            // Register the event handlers.
        
              this.BugsSummaryRecordRowCopyButton1.Click += new ImageClickEventHandler(BugsSummaryRecordRowCopyButton1_Click);
              this.BugsSummaryRecordRowDeleteButton1.Click += new ImageClickEventHandler(BugsSummaryRecordRowDeleteButton1_Click);
              this.BugsSummaryRecordRowEditButton1.Click += new ImageClickEventHandler(BugsSummaryRecordRowEditButton1_Click);
              this.BugsSummaryRecordRowViewButton1.Click += new ImageClickEventHandler(BugsSummaryRecordRowViewButton1_Click);
              this.Assigned1.Click += new EventHandler(Assigned1_Click);
            
              this.FixedBy1.Click += new EventHandler(FixedBy1_Click);
            
              this.PriorityID1.Click += new EventHandler(PriorityID1_Click);
            
              this.StatusID1.Click += new EventHandler(StatusID1_Click);
            
              this.TaskID1.Click += new EventHandler(TaskID1_Click);
            
              this.TestCaseID1.Click += new EventHandler(TestCaseID1_Click);
            
              this.UserId2.Click += new EventHandler(UserId2_Click);
            
        }

        // To customize, override this method in BugsSummaryTableControl1Row.
        protected virtual void Control_Load(object sender, System.EventArgs e)
        {
        
                // Show confirmation message on Click
                this.BugsSummaryRecordRowDeleteButton1.Attributes.Add("onClick", "return (confirm('" + ((BaseApplicationPage)this.Page).GetResourceValue("DeleteRecordConfirm", "BUGLOG") + "'));");
        }

        // Read data from database. To customize, override this method in BugsSummaryTableControl1Row.
        public virtual void LoadData()  
        {
        
            if (this.RecordUniqueId != null && this.RecordUniqueId.Length > 0) {
                this.DataSource = BugsSummaryTable.GetRecord(this.RecordUniqueId, true);
                return;
            }
        
            // Since this is a row in the table, the data for this row is loaded by the 
            // LoadData method of the BaseBugsSummaryTableControl1 when the data for the entire
            // table is loaded.
            this.DataSource = new BugsSummaryRecord();
          
        }

        // Populate the UI controls using the DataSource. To customize, override this method in BugsSummaryTableControl1Row.
        public override void DataBind()
        {
            base.DataBind();

            // Make sure that the DataSource is initialized.
            if (this.DataSource == null) {
                return;
            }
        
            // Store the checksum. The checksum is used to
            // ensure the record was not changed by another user.
            if ((this.DataSource.GetCheckSumValue() != null) &&
                (this.CheckSum == null || this.CheckSum.Trim().Length == 0)) {
                this.CheckSum = this.DataSource.GetCheckSumValue().Value;
            }

            // For each field, check to see if a value is specified.  If a value is specified,
            // then format the value for display.  If no value is specified, use the default value (formatted).

        
            if (this.DataSource.AssignedSpecified) {
                      
                string formattedValue = this.DataSource.Format(BugsSummaryTable.Assigned);
                this.Assigned1.Text = formattedValue;
                        
            } else {  
                this.Assigned1.Text = BugsSummaryTable.Assigned.Format(BugsSummaryTable.Assigned.DefaultValue);
            }
                    
            if (this.DataSource.BugIdSpecified) {
                      
                string formattedValue = this.DataSource.Format(BugsSummaryTable.BugId);
                formattedValue = HttpUtility.HtmlEncode(formattedValue);
                if (formattedValue != null) {
                    // If formattedValue's length exceeds FieldMaxLength value (100) then, display till FieldMaxLength value
                    if (formattedValue.Length > (int)(100)){
                        formattedValue = NetUtils.EncodeStringForHtmlDisplay(formattedValue.Substring(0, 100)) + "...";
                    }
                }           
                this.BugId1.Text = formattedValue;
                        
            } else {  
                this.BugId1.Text = BugsSummaryTable.BugId.Format(BugsSummaryTable.BugId.DefaultValue);
            }
                    
            if (this.BugId1.Text == null ||
                this.BugId1.Text.Trim().Length == 0) {
                this.BugId1.Text = "&nbsp;";
            }
                  
            if (this.DataSource.BugShortDescriptionSpecified) {
                      
                string formattedValue = this.DataSource.Format(BugsSummaryTable.BugShortDescription);
                formattedValue = HttpUtility.HtmlEncode(formattedValue);
                if (formattedValue != null) {
                    // If formattedValue's length exceeds FieldMaxLength value (100) then, display till FieldMaxLength value
                    if (formattedValue.Length > (int)(100)){
                        formattedValue = NetUtils.EncodeStringForHtmlDisplay(formattedValue.Substring(0, 100)) + "...";
                    }
                }           
                this.BugShortDescription1.Text = formattedValue;
                        
            } else {  
                this.BugShortDescription1.Text = BugsSummaryTable.BugShortDescription.Format(BugsSummaryTable.BugShortDescription.DefaultValue);
            }
                    
            if (this.BugShortDescription1.Text == null ||
                this.BugShortDescription1.Text.Trim().Length == 0) {
                this.BugShortDescription1.Text = "&nbsp;";
            }
                  
            if (this.DataSource.Date0Specified) {
                      
                string formattedValue = this.DataSource.Format(BugsSummaryTable.Date0);
                formattedValue = HttpUtility.HtmlEncode(formattedValue);
                if (formattedValue != null) {
                    // If formattedValue's length exceeds FieldMaxLength value (100) then, display till FieldMaxLength value
                    if (formattedValue.Length > (int)(100)){
                        formattedValue = NetUtils.EncodeStringForHtmlDisplay(formattedValue.Substring(0, 100)) + "...";
                    }
                }           
                this.Date2.Text = formattedValue;
                        
            } else {  
                this.Date2.Text = BugsSummaryTable.Date0.Format(BugsSummaryTable.Date0.DefaultValue);
            }
                    
            if (this.Date2.Text == null ||
                this.Date2.Text.Trim().Length == 0) {
                this.Date2.Text = "&nbsp;";
            }
                  
            if (this.DataSource.DescriptionSpecified) {
                      
                string formattedValue = this.DataSource.Format(BugsSummaryTable.Description);
                formattedValue = HttpUtility.HtmlEncode(formattedValue);
                if(formattedValue != null){
                    int popupThreshold = (int)(100);
                              
                    int maxLength = formattedValue.Length;
                    if (maxLength > (int)(100)){
                        maxLength = (int)(100);
                    }
                                
                    if (formattedValue.Length >= popupThreshold) {
                              
                         formattedValue = "<a OnClick=\'gPersist=true;\' OnMouseOut=\'detailRolloverPopupClose();\'" +
                              "OnMouseOver=\'SaveMousePosition(event); delayRolloverPopup(\"PageMethods.GetRecordFieldValue(\\\"BUGLOG.Business.BugsSummaryTable, App_Code\\\",\\\"" +
                              this.DataSource.GetID().ToString() + "\\\", \\\"Description\\\", \\\"Description\\\"," +
                              " false, 200," +
                              " 300, true, PopupDisplayWindowCallBackWith20);\", 500);'>" + NetUtils.EncodeStringForHtmlDisplay(formattedValue.Substring(0, maxLength)) + "..." + "</a>";
                    }
                    else{
                        if (formattedValue.Length > maxLength) {
                            formattedValue = NetUtils.EncodeStringForHtmlDisplay(formattedValue.Substring(0,maxLength));
                        }
                    }
                }
                this.Description1.Text = formattedValue;
                            
            } else {  
                this.Description1.Text = BugsSummaryTable.Description.Format(BugsSummaryTable.Description.DefaultValue);
            }
                    
            if (this.Description1.Text == null ||
                this.Description1.Text.Trim().Length == 0) {
                this.Description1.Text = "&nbsp;";
            }
                  
            if (this.DataSource.EnvBUGLOGmentSpecified) {
                      
                string formattedValue = this.DataSource.Format(BugsSummaryTable.EnvBUGLOGment);
                formattedValue = HttpUtility.HtmlEncode(formattedValue);
                if(formattedValue != null){
                    int popupThreshold = (int)(100);
                              
                    int maxLength = formattedValue.Length;
                    if (maxLength > (int)(100)){
                        maxLength = (int)(100);
                    }
                                
                    if (formattedValue.Length >= popupThreshold) {
                              
                         formattedValue = "<a OnClick=\'gPersist=true;\' OnMouseOut=\'detailRolloverPopupClose();\'" +
                              "OnMouseOver=\'SaveMousePosition(event); delayRolloverPopup(\"PageMethods.GetRecordFieldValue(\\\"BUGLOG.Business.BugsSummaryTable, App_Code\\\",\\\"" +
                              this.DataSource.GetID().ToString() + "\\\", \\\"EnvBUGLOGment\\\", \\\"EnvBUGLOGment\\\"," +
                              " false, 200," +
                              " 300, true, PopupDisplayWindowCallBackWith20);\", 500);'>" + NetUtils.EncodeStringForHtmlDisplay(formattedValue.Substring(0, maxLength)) + "..." + "</a>";
                    }
                    else{
                        if (formattedValue.Length > maxLength) {
                            formattedValue = NetUtils.EncodeStringForHtmlDisplay(formattedValue.Substring(0,maxLength));
                        }
                    }
                }
                this.EnvBUGLOGment1.Text = formattedValue;
                            
            } else {  
                this.EnvBUGLOGment1.Text = BugsSummaryTable.EnvBUGLOGment.Format(BugsSummaryTable.EnvBUGLOGment.DefaultValue);
            }
                    
            if (this.EnvBUGLOGment1.Text == null ||
                this.EnvBUGLOGment1.Text.Trim().Length == 0) {
                this.EnvBUGLOGment1.Text = "&nbsp;";
            }
                  
            if (this.DataSource.FixedBySpecified) {
                      
                string formattedValue = this.DataSource.Format(BugsSummaryTable.FixedBy);
                this.FixedBy1.Text = formattedValue;
                        
            } else {  
                this.FixedBy1.Text = BugsSummaryTable.FixedBy.Format(BugsSummaryTable.FixedBy.DefaultValue);
            }
                    
            if (this.DataSource.ImageAttachmentSpecified) {
                  
                this.ImageAttachment1.Attributes.Add("OnClick", "gPersist=true;");
                this.ImageAttachment1.Attributes.Add("OnMouseOut","detailRolloverPopupClose();");
                this.ImageAttachment1.Attributes.Add("OnMouseOver","SaveMousePosition(event);delayRolloverPopup(\"PageMethods.GetImage(\\\"BugsSummary\\\", \\\"" +
                    this.DataSource.GetID().ToString() + "\\\", \\\"ImageAttachment\\\", \\\"Image Attachment\\\"," +
                    " false, 200," +
                    " 300, true, PopupDisplayWindowCallBackWith20);\", 500);");
                this.ImageAttachment1.ImageUrl = this.DataSource.FormatImageUrl(BugsSummaryTable.ImageAttachment, "BugsSummary", "ImageAttachment", this.DataSource.GetID().ToXmlString(),20);
                            
            } 
            else {
                this.ImageAttachment1.Visible = false;
            }
                
            if (this.DataSource.NoteSpecified) {
                      
                string formattedValue = this.DataSource.Format(BugsSummaryTable.Note);
                formattedValue = HttpUtility.HtmlEncode(formattedValue);
                if(formattedValue != null){
                    int popupThreshold = (int)(100);
                              
                    int maxLength = formattedValue.Length;
                    if (maxLength > (int)(100)){
                        maxLength = (int)(100);
                    }
                                
                    if (formattedValue.Length >= popupThreshold) {
                              
                         formattedValue = "<a OnClick=\'gPersist=true;\' OnMouseOut=\'detailRolloverPopupClose();\'" +
                              "OnMouseOver=\'SaveMousePosition(event); delayRolloverPopup(\"PageMethods.GetRecordFieldValue(\\\"BUGLOG.Business.BugsSummaryTable, App_Code\\\",\\\"" +
                              this.DataSource.GetID().ToString() + "\\\", \\\"Note\\\", \\\"Note\\\"," +
                              " false, 200," +
                              " 300, true, PopupDisplayWindowCallBackWith20);\", 500);'>" + NetUtils.EncodeStringForHtmlDisplay(formattedValue.Substring(0, maxLength)) + "..." + "</a>";
                    }
                    else{
                        if (formattedValue.Length > maxLength) {
                            formattedValue = NetUtils.EncodeStringForHtmlDisplay(formattedValue.Substring(0,maxLength));
                        }
                    }
                }
                this.Note1.Text = formattedValue;
                            
            } else {  
                this.Note1.Text = BugsSummaryTable.Note.Format(BugsSummaryTable.Note.DefaultValue);
            }
                    
            if (this.Note1.Text == null ||
                this.Note1.Text.Trim().Length == 0) {
                this.Note1.Text = "&nbsp;";
            }
                  
            if (this.DataSource.PriorityIDSpecified) {
                      
                string formattedValue = this.DataSource.Format(BugsSummaryTable.PriorityID);
                this.PriorityID1.Text = formattedValue;
                        
            } else {  
                this.PriorityID1.Text = BugsSummaryTable.PriorityID.Format(BugsSummaryTable.PriorityID.DefaultValue);
            }
                    
            if (this.DataSource.StatusIDSpecified) {
                      
                string formattedValue = this.DataSource.Format(BugsSummaryTable.StatusID);
                this.StatusID1.Text = formattedValue;
                        
            } else {  
                this.StatusID1.Text = BugsSummaryTable.StatusID.Format(BugsSummaryTable.StatusID.DefaultValue);
            }
                    
            if (this.DataSource.StepsToReproduceSpecified) {
                      
                string formattedValue = this.DataSource.Format(BugsSummaryTable.StepsToReproduce);
                formattedValue = HttpUtility.HtmlEncode(formattedValue);
                if(formattedValue != null){
                    int popupThreshold = (int)(100);
                              
                    int maxLength = formattedValue.Length;
                    if (maxLength > (int)(100)){
                        maxLength = (int)(100);
                    }
                                
                    if (formattedValue.Length >= popupThreshold) {
                              
                         formattedValue = "<a OnClick=\'gPersist=true;\' OnMouseOut=\'detailRolloverPopupClose();\'" +
                              "OnMouseOver=\'SaveMousePosition(event); delayRolloverPopup(\"PageMethods.GetRecordFieldValue(\\\"BUGLOG.Business.BugsSummaryTable, App_Code\\\",\\\"" +
                              this.DataSource.GetID().ToString() + "\\\", \\\"StepsToReproduce\\\", \\\"Steps To Reproduce\\\"," +
                              " false, 200," +
                              " 300, true, PopupDisplayWindowCallBackWith20);\", 500);'>" + NetUtils.EncodeStringForHtmlDisplay(formattedValue.Substring(0, maxLength)) + "..." + "</a>";
                    }
                    else{
                        if (formattedValue.Length > maxLength) {
                            formattedValue = NetUtils.EncodeStringForHtmlDisplay(formattedValue.Substring(0,maxLength));
                        }
                    }
                }
                this.StepsToReproduce1.Text = formattedValue;
                            
            } else {  
                this.StepsToReproduce1.Text = BugsSummaryTable.StepsToReproduce.Format(BugsSummaryTable.StepsToReproduce.DefaultValue);
            }
                    
            if (this.StepsToReproduce1.Text == null ||
                this.StepsToReproduce1.Text.Trim().Length == 0) {
                this.StepsToReproduce1.Text = "&nbsp;";
            }
                  
            if (this.DataSource.TaskIDSpecified) {
                      
                string formattedValue = this.DataSource.Format(BugsSummaryTable.TaskID);
                this.TaskID1.Text = formattedValue;
                        
            } else {  
                this.TaskID1.Text = BugsSummaryTable.TaskID.Format(BugsSummaryTable.TaskID.DefaultValue);
            }
                    
            if (this.DataSource.TestCaseIDSpecified) {
                      
                string formattedValue = this.DataSource.Format(BugsSummaryTable.TestCaseID);
                this.TestCaseID1.Text = formattedValue;
                        
            } else {  
                this.TestCaseID1.Text = BugsSummaryTable.TestCaseID.Format(BugsSummaryTable.TestCaseID.DefaultValue);
            }
                    
            if (this.DataSource.UserId0Specified) {
                      
                string formattedValue = this.DataSource.Format(BugsSummaryTable.UserId0);
                this.UserId2.Text = formattedValue;
                        
            } else {  
                this.UserId2.Text = BugsSummaryTable.UserId0.Format(BugsSummaryTable.UserId0.DefaultValue);
            }
                    
            this.IsNewRecord = true;
            if (this.DataSource.IsCreated) {
                this.IsNewRecord = false;
        
                this.RecordUniqueId = this.DataSource.GetID().ToXmlString();
            }

            

            // Load data for each record and table UI control.
            // Ordering is important because child controls get 
            // their parent ids from their parent UI controls.
            
        }

        //  To customize, override this method in BugsSummaryTableControl1Row.
        public virtual void SaveData()
        {
            // 1. Load the existing record from the database. Since we save the entire reocrd, this ensures 
            // that fields that are not displayed also properly initialized.
            this.LoadData();
        
            // The checksum is used to ensure the record was not changed by another user.
            if (this.DataSource.GetCheckSumValue() != null) {
                if (this.CheckSum != null && this.CheckSum != this.DataSource.GetCheckSumValue().Value) {
                    throw new Exception(Page.GetResourceValue("Err:RecChangedByOtherUser", "BUGLOG"));
                }
            }
        
            // 2. Validate the data.  Override in BugsSummaryTableControl1Row to add custom validation.
            this.Validate();

            // 3. Set the values in the record with data from UI controls.  Override in BugsSummaryTableControl1Row to set additional fields.
            this.GetUIData();

            // 4. Save in the database.
            // We should not save the record if the data did not change. This
            // will save a database hit and avoid triggering any database triggers.
            if (this.DataSource.IsAnyValueChanged) {
                // Save record to database but do not commit.
                // Auto generated ids are available after saving for use by child (dependent) records.
                this.DataSource.Save();
              
                ((BugsSummaryTableControl1)MiscUtils.GetParentControlObject(this, "BugsSummaryTableControl1")).DataChanged = true;
                ((BugsSummaryTableControl1)MiscUtils.GetParentControlObject(this, "BugsSummaryTableControl1")).ResetData = true;
            }
            // Reseting of this.IsNewRecord is moved to Save button's click even handler.
            // this.IsNewRecord = false;
            this.DataChanged = true;
            this.ResetData = true;
            
            this.CheckSum = "";
        }

        //  To customize, override this method in BugsSummaryTableControl1Row.
        public virtual void GetUIData()
        {
        
        }

        //  To customize, override this method in BugsSummaryTableControl1Row.
        public virtual WhereClause CreateWhereClause()
        {
        
            return null;
          
        }
        

        //  To customize, override this method in BugsSummaryTableControl1Row.
        public virtual void Validate()
        {
            // Initially empty.  Override to add custom validation.
        }

        public virtual void Delete()
        {
        
            if (this.IsNewRecord) {
                return;
            }

            KeyValue pk = KeyValue.XmlToKey(this.RecordUniqueId);
            BugsSummaryTable.DeleteRecord(pk);

          
            ((BugsSummaryTableControl1)MiscUtils.GetParentControlObject(this, "BugsSummaryTableControl1")).DataChanged = true;
            ((BugsSummaryTableControl1)MiscUtils.GetParentControlObject(this, "BugsSummaryTableControl1")).ResetData = true;
        }

        private void Control_PreRender(object sender, System.EventArgs e)
        {
            try {
                DbUtils.StartTransaction();

                if (!this.Page.ErrorOnPage && (this.Page.IsPageRefresh || this.DataChanged || this.ResetData)) {
                    this.LoadData();
                    this.DataBind();
                }

            } catch (Exception ex) {
                BaseClasses.Utils.MiscUtils.RegisterJScriptAlert(this, "BUTTON_CLICK_MESSAGE", ex.Message);
            } finally {
                DbUtils.EndTransaction();
            }
        }
        
        protected override void LoadViewState(object savedState)
        {
            base.LoadViewState(savedState);
            string isNewRecord = (string)ViewState["IsNewRecord"];
            if (isNewRecord != null && isNewRecord.Length > 0) {
                this.IsNewRecord = Boolean.Parse(isNewRecord);
            }
            string myCheckSum = (string)ViewState["CheckSum"];
            if (myCheckSum != null && myCheckSum.Length > 0) {
                this.CheckSum = myCheckSum;
            }
        }

        protected override object SaveViewState()
        {
            ViewState["IsNewRecord"] = this.IsNewRecord.ToString();
            ViewState["CheckSum"] = this.CheckSum;
            return base.SaveViewState();
        }
        
              // event handler for ImageButton
              public virtual void BugsSummaryRecordRowCopyButton1_Click(object sender, ImageClickEventArgs args)
              {
              
            string url = @"../BugsSummary/AddBugsSummaryPage.aspx?BugsSummary={PK}";
            bool shouldRedirect = true;
            string TargetKey = null;
            string DFKA = null;
            string id = null;
            string value = null;
            try {
                DbUtils.StartTransaction();
                
                url = this.ModifyRedirectUrl(url, "",false);
                url = this.Page.ModifyRedirectUrl(url, "",false);
                        this.Page.CommitTransaction(sender);
      
            } catch (Exception ex) {
                this.Page.RollBackTransaction(sender);
                shouldRedirect = false;
                this.Page.ErrorOnPage = true;
    
                throw ex;
            } finally {
                DbUtils.EndTransaction();
            }
            if (shouldRedirect) {
                this.Page.ShouldSaveControlsToSession = true;
                this.Page.Response.Redirect(url);
            }
        
            else if (TargetKey != null && !shouldRedirect){
            this.Page.ShouldSaveControlsToSession = true ; 
            this.Page.CloseWindow(true);
            }
        
              }
            
              // event handler for ImageButton
              public virtual void BugsSummaryRecordRowDeleteButton1_Click(object sender, ImageClickEventArgs args)
              {
              
            try {
                DbUtils.StartTransaction();
                
            if (!this.Page.IsPageRefresh) {
        
                this.Delete();
              
            }
                this.Page.CommitTransaction(sender);
      
            } catch (Exception ex) {
                this.Page.RollBackTransaction(sender);
                this.Page.ErrorOnPage = true;
    
                throw ex;
            } finally {
                DbUtils.EndTransaction();
            }
    
              }
            
              // event handler for ImageButton
              public virtual void BugsSummaryRecordRowEditButton1_Click(object sender, ImageClickEventArgs args)
              {
              
            string url = @"../BugsSummary/EditBugsSummaryPage.aspx?BugsSummary={PK}";
            bool shouldRedirect = true;
            string TargetKey = null;
            string DFKA = null;
            string id = null;
            string value = null;
            try {
                DbUtils.StartTransaction();
                
                url = this.ModifyRedirectUrl(url, "",false);
                url = this.Page.ModifyRedirectUrl(url, "",false);
                        this.Page.CommitTransaction(sender);
      
            } catch (Exception ex) {
                this.Page.RollBackTransaction(sender);
                shouldRedirect = false;
                this.Page.ErrorOnPage = true;
    
                throw ex;
            } finally {
                DbUtils.EndTransaction();
            }
            if (shouldRedirect) {
                this.Page.ShouldSaveControlsToSession = true;
                this.Page.Response.Redirect(url);
            }
        
            else if (TargetKey != null && !shouldRedirect){
            this.Page.ShouldSaveControlsToSession = true ; 
            this.Page.CloseWindow(true);
            }
        
              }
            
              // event handler for ImageButton
              public virtual void BugsSummaryRecordRowViewButton1_Click(object sender, ImageClickEventArgs args)
              {
              
            string url = @"../BugsSummary/ShowBugsSummaryPage.aspx?BugsSummary={PK}";
            bool shouldRedirect = true;
            string TargetKey = null;
            string DFKA = null;
            string id = null;
            string value = null;
            try {
                DbUtils.StartTransaction();
                
                url = this.ModifyRedirectUrl(url, "",false);
                url = this.Page.ModifyRedirectUrl(url, "",false);
                        this.Page.CommitTransaction(sender);
      
            } catch (Exception ex) {
                this.Page.RollBackTransaction(sender);
                shouldRedirect = false;
                this.Page.ErrorOnPage = true;
    
                throw ex;
            } finally {
                DbUtils.EndTransaction();
            }
            if (shouldRedirect) {
                this.Page.ShouldSaveControlsToSession = true;
                this.Page.Response.Redirect(url);
            }
        
            else if (TargetKey != null && !shouldRedirect){
            this.Page.ShouldSaveControlsToSession = true ; 
            this.Page.CloseWindow(true);
            }
        
              }
            
              // event handler for LinkButton
              public virtual void Assigned1_Click(object sender, EventArgs args)
              {
              
            string url = @"../Users/ShowUsersPage.aspx?Users={BugsSummaryTableControl1Row:FK:FK_BugsSummary_Users1}";
            bool shouldRedirect = true;
            string TargetKey = null;
            string DFKA = null;
            string id = null;
            string value = null;
            try {
                DbUtils.StartTransaction();
                
                url = this.ModifyRedirectUrl(url, "",false);
                url = this.Page.ModifyRedirectUrl(url, "",false);
                        this.Page.CommitTransaction(sender);
      
            } catch (Exception ex) {
                this.Page.RollBackTransaction(sender);
                shouldRedirect = false;
                this.Page.ErrorOnPage = true;
    
                throw ex;
            } finally {
                DbUtils.EndTransaction();
            }
            if (shouldRedirect) {
                this.Page.ShouldSaveControlsToSession = true;
                this.Page.Response.Redirect(url);
            }
        
            else if (TargetKey != null && !shouldRedirect){
            this.Page.ShouldSaveControlsToSession = true ; 
            this.Page.CloseWindow(true);
            }
        
              }
            
              // event handler for LinkButton
              public virtual void FixedBy1_Click(object sender, EventArgs args)
              {
              
            string url = @"../Users/ShowUsersPage.aspx?Users={BugsSummaryTableControl1Row:FK:FK_BugsSummary_Users2}";
            bool shouldRedirect = true;
            string TargetKey = null;
            string DFKA = null;
            string id = null;
            string value = null;
            try {
                DbUtils.StartTransaction();
                
                url = this.ModifyRedirectUrl(url, "",false);
                url = this.Page.ModifyRedirectUrl(url, "",false);
                        this.Page.CommitTransaction(sender);
      
            } catch (Exception ex) {
                this.Page.RollBackTransaction(sender);
                shouldRedirect = false;
                this.Page.ErrorOnPage = true;
    
                throw ex;
            } finally {
                DbUtils.EndTransaction();
            }
            if (shouldRedirect) {
                this.Page.ShouldSaveControlsToSession = true;
                this.Page.Response.Redirect(url);
            }
        
            else if (TargetKey != null && !shouldRedirect){
            this.Page.ShouldSaveControlsToSession = true ; 
            this.Page.CloseWindow(true);
            }
        
              }
            
              // event handler for LinkButton
              public virtual void PriorityID1_Click(object sender, EventArgs args)
              {
              
            string url = @"../PriorityLevel/ShowPriorityLevelPage.aspx?PriorityLevel={BugsSummaryTableControl1Row:FK:FK_BugsSummary_PriorityLevel}";
            bool shouldRedirect = true;
            string TargetKey = null;
            string DFKA = null;
            string id = null;
            string value = null;
            try {
                DbUtils.StartTransaction();
                
                url = this.ModifyRedirectUrl(url, "",false);
                url = this.Page.ModifyRedirectUrl(url, "",false);
                        this.Page.CommitTransaction(sender);
      
            } catch (Exception ex) {
                this.Page.RollBackTransaction(sender);
                shouldRedirect = false;
                this.Page.ErrorOnPage = true;
    
                throw ex;
            } finally {
                DbUtils.EndTransaction();
            }
            if (shouldRedirect) {
                this.Page.ShouldSaveControlsToSession = true;
                this.Page.Response.Redirect(url);
            }
        
            else if (TargetKey != null && !shouldRedirect){
            this.Page.ShouldSaveControlsToSession = true ; 
            this.Page.CloseWindow(true);
            }
        
              }
            
              // event handler for LinkButton
              public virtual void StatusID1_Click(object sender, EventArgs args)
              {
              
            string url = @"../Status/ShowStatusPage.aspx?Status={BugsSummaryTableControl1Row:FK:FK_BugsSummary_Status}";
            bool shouldRedirect = true;
            string TargetKey = null;
            string DFKA = null;
            string id = null;
            string value = null;
            try {
                DbUtils.StartTransaction();
                
                url = this.ModifyRedirectUrl(url, "",false);
                url = this.Page.ModifyRedirectUrl(url, "",false);
                        this.Page.CommitTransaction(sender);
      
            } catch (Exception ex) {
                this.Page.RollBackTransaction(sender);
                shouldRedirect = false;
                this.Page.ErrorOnPage = true;
    
                throw ex;
            } finally {
                DbUtils.EndTransaction();
            }
            if (shouldRedirect) {
                this.Page.ShouldSaveControlsToSession = true;
                this.Page.Response.Redirect(url);
            }
        
            else if (TargetKey != null && !shouldRedirect){
            this.Page.ShouldSaveControlsToSession = true ; 
            this.Page.CloseWindow(true);
            }
        
              }
            
              // event handler for LinkButton
              public virtual void TaskID1_Click(object sender, EventArgs args)
              {
              
            string url = @"../Task/ShowTaskPage.aspx?Task={BugsSummaryTableControl1Row:FK:FK_BugsSummary_Task}";
            bool shouldRedirect = true;
            string TargetKey = null;
            string DFKA = null;
            string id = null;
            string value = null;
            try {
                DbUtils.StartTransaction();
                
                url = this.ModifyRedirectUrl(url, "",false);
                url = this.Page.ModifyRedirectUrl(url, "",false);
                        this.Page.CommitTransaction(sender);
      
            } catch (Exception ex) {
                this.Page.RollBackTransaction(sender);
                shouldRedirect = false;
                this.Page.ErrorOnPage = true;
    
                throw ex;
            } finally {
                DbUtils.EndTransaction();
            }
            if (shouldRedirect) {
                this.Page.ShouldSaveControlsToSession = true;
                this.Page.Response.Redirect(url);
            }
        
            else if (TargetKey != null && !shouldRedirect){
            this.Page.ShouldSaveControlsToSession = true ; 
            this.Page.CloseWindow(true);
            }
        
              }
            
              // event handler for LinkButton
              public virtual void TestCaseID1_Click(object sender, EventArgs args)
              {
              
            string url = @"../TestCases/ShowTestCasesPage.aspx?TestCases={BugsSummaryTableControl1Row:FK:FK_BugsSummary_TestCases}";
            bool shouldRedirect = true;
            string TargetKey = null;
            string DFKA = null;
            string id = null;
            string value = null;
            try {
                DbUtils.StartTransaction();
                
                url = this.ModifyRedirectUrl(url, "",false);
                url = this.Page.ModifyRedirectUrl(url, "",false);
                        this.Page.CommitTransaction(sender);
      
            } catch (Exception ex) {
                this.Page.RollBackTransaction(sender);
                shouldRedirect = false;
                this.Page.ErrorOnPage = true;
    
                throw ex;
            } finally {
                DbUtils.EndTransaction();
            }
            if (shouldRedirect) {
                this.Page.ShouldSaveControlsToSession = true;
                this.Page.Response.Redirect(url);
            }
        
            else if (TargetKey != null && !shouldRedirect){
            this.Page.ShouldSaveControlsToSession = true ; 
            this.Page.CloseWindow(true);
            }
        
              }
            
              // event handler for LinkButton
              public virtual void UserId2_Click(object sender, EventArgs args)
              {
              
            string url = @"../Users/ShowUsersPage.aspx?Users={BugsSummaryTableControl1Row:FK:FK_BugsSummary_Users}";
            bool shouldRedirect = true;
            string TargetKey = null;
            string DFKA = null;
            string id = null;
            string value = null;
            try {
                DbUtils.StartTransaction();
                
                url = this.ModifyRedirectUrl(url, "",false);
                url = this.Page.ModifyRedirectUrl(url, "",false);
                        this.Page.CommitTransaction(sender);
      
            } catch (Exception ex) {
                this.Page.RollBackTransaction(sender);
                shouldRedirect = false;
                this.Page.ErrorOnPage = true;
    
                throw ex;
            } finally {
                DbUtils.EndTransaction();
            }
            if (shouldRedirect) {
                this.Page.ShouldSaveControlsToSession = true;
                this.Page.Response.Redirect(url);
            }
        
            else if (TargetKey != null && !shouldRedirect){
            this.Page.ShouldSaveControlsToSession = true ; 
            this.Page.CloseWindow(true);
            }
        
              }
            
        private bool _IsNewRecord = true;
        public virtual bool IsNewRecord {
            get {
                return this._IsNewRecord;
            }
            set {
                this._IsNewRecord = value;
            }
        }

        private bool _DataChanged = false;
        public virtual bool DataChanged {
            get {
                return this._DataChanged;
            }
            set {
                this._DataChanged = value;
            }
        }

        private bool _ResetData = false;
        public virtual bool ResetData {
            get {
                return (this._ResetData);
            }
            set {
                this._ResetData = value;
            }
        }
        
        public String RecordUniqueId {
            get {
                return (string)this.ViewState["BaseBugsSummaryTableControl1Row_Rec"];
            }
            set {
                this.ViewState["BaseBugsSummaryTableControl1Row_Rec"] = value;
            }
        }
        
        private BugsSummaryRecord _DataSource;
        public BugsSummaryRecord DataSource {
            get {
                return (this._DataSource);
            }
            set {
                this._DataSource = value;
            }
        }

        private string _checkSum;
        public virtual string CheckSum {
            get {
                return (this._checkSum);
            }
            set {
                this._checkSum = value;
            }
        }

#region "Helper Properties"
           
        public System.Web.UI.WebControls.LinkButton Assigned1 {
            get {
                return (System.Web.UI.WebControls.LinkButton)BaseClasses.Utils.MiscUtils.FindControlRecursively(this, "Assigned1");
            }
        }
           
        public System.Web.UI.WebControls.Literal BugId1 {
            get {
                return (System.Web.UI.WebControls.Literal)BaseClasses.Utils.MiscUtils.FindControlRecursively(this, "BugId1");
            }
        }
           
        public System.Web.UI.WebControls.Literal BugShortDescription1 {
            get {
                return (System.Web.UI.WebControls.Literal)BaseClasses.Utils.MiscUtils.FindControlRecursively(this, "BugShortDescription1");
            }
        }
        
        public System.Web.UI.WebControls.ImageButton BugsSummaryRecordRowCopyButton1 {
            get {
                return (System.Web.UI.WebControls.ImageButton)BaseClasses.Utils.MiscUtils.FindControlRecursively(this, "BugsSummaryRecordRowCopyButton1");
            }
        }
        
        public System.Web.UI.WebControls.ImageButton BugsSummaryRecordRowDeleteButton1 {
            get {
                return (System.Web.UI.WebControls.ImageButton)BaseClasses.Utils.MiscUtils.FindControlRecursively(this, "BugsSummaryRecordRowDeleteButton1");
            }
        }
        
        public System.Web.UI.WebControls.ImageButton BugsSummaryRecordRowEditButton1 {
            get {
                return (System.Web.UI.WebControls.ImageButton)BaseClasses.Utils.MiscUtils.FindControlRecursively(this, "BugsSummaryRecordRowEditButton1");
            }
        }
        
        public System.Web.UI.WebControls.CheckBox BugsSummaryRecordRowSelection1 {
            get {
                return (System.Web.UI.WebControls.CheckBox)BaseClasses.Utils.MiscUtils.FindControlRecursively(this, "BugsSummaryRecordRowSelection1");
            }
        }
        
        public System.Web.UI.WebControls.ImageButton BugsSummaryRecordRowViewButton1 {
            get {
                return (System.Web.UI.WebControls.ImageButton)BaseClasses.Utils.MiscUtils.FindControlRecursively(this, "BugsSummaryRecordRowViewButton1");
            }
        }
           
        public System.Web.UI.WebControls.Literal Date2 {
            get {
                return (System.Web.UI.WebControls.Literal)BaseClasses.Utils.MiscUtils.FindControlRecursively(this, "Date2");
            }
        }
           
        public System.Web.UI.WebControls.Literal Description1 {
            get {
                return (System.Web.UI.WebControls.Literal)BaseClasses.Utils.MiscUtils.FindControlRecursively(this, "Description1");
            }
        }
           
        public System.Web.UI.WebControls.Literal EnvBUGLOGment1 {
            get {
                return (System.Web.UI.WebControls.Literal)BaseClasses.Utils.MiscUtils.FindControlRecursively(this, "EnvBUGLOGment1");
            }
        }
           
        public System.Web.UI.WebControls.LinkButton FixedBy1 {
            get {
                return (System.Web.UI.WebControls.LinkButton)BaseClasses.Utils.MiscUtils.FindControlRecursively(this, "FixedBy1");
            }
        }
           
        public System.Web.UI.WebControls.Image ImageAttachment1 {
            get {
                return (System.Web.UI.WebControls.Image)BaseClasses.Utils.MiscUtils.FindControlRecursively(this, "ImageAttachment1");
            }
        }
           
        public System.Web.UI.WebControls.Literal Note1 {
            get {
                return (System.Web.UI.WebControls.Literal)BaseClasses.Utils.MiscUtils.FindControlRecursively(this, "Note1");
            }
        }
           
        public System.Web.UI.WebControls.LinkButton PriorityID1 {
            get {
                return (System.Web.UI.WebControls.LinkButton)BaseClasses.Utils.MiscUtils.FindControlRecursively(this, "PriorityID1");
            }
        }
           
        public System.Web.UI.WebControls.LinkButton StatusID1 {
            get {
                return (System.Web.UI.WebControls.LinkButton)BaseClasses.Utils.MiscUtils.FindControlRecursively(this, "StatusID1");
            }
        }
           
        public System.Web.UI.WebControls.Literal StepsToReproduce1 {
            get {
                return (System.Web.UI.WebControls.Literal)BaseClasses.Utils.MiscUtils.FindControlRecursively(this, "StepsToReproduce1");
            }
        }
           
        public System.Web.UI.WebControls.LinkButton TaskID1 {
            get {
                return (System.Web.UI.WebControls.LinkButton)BaseClasses.Utils.MiscUtils.FindControlRecursively(this, "TaskID1");
            }
        }
           
        public System.Web.UI.WebControls.LinkButton TestCaseID1 {
            get {
                return (System.Web.UI.WebControls.LinkButton)BaseClasses.Utils.MiscUtils.FindControlRecursively(this, "TestCaseID1");
            }
        }
           
        public System.Web.UI.WebControls.LinkButton UserId2 {
            get {
                return (System.Web.UI.WebControls.LinkButton)BaseClasses.Utils.MiscUtils.FindControlRecursively(this, "UserId2");
            }
        }
        
#endregion

#region "Helper Functions"
    
        public override string ModifyRedirectUrl(string url, string arg, bool bEncrypt)
      
        {
            BugsSummaryRecord rec = null;
            try {
                rec = this.GetRecord();
            }
            catch (Exception ex) {
                // Do Nothing
            }
            
      if (rec == null && url.IndexOf("{") >= 0) {
                // Localization.
                throw new Exception(Page.GetResourceValue("Err:RecDataSrcNotInitialized", "BUGLOG"));
            }
    
        return ModifyRedirectUrl(url, arg, rec, bEncrypt);
      
        }

        public BugsSummaryRecord GetRecord()
        {
        
            if (this.DataSource != null) {
                return this.DataSource;
            }
            
            if (this.RecordUniqueId != null) {
                return BugsSummaryTable.GetRecord(this.RecordUniqueId, true);
            }
            
            // Localization.
            throw new Exception(Page.GetResourceValue("Err:RetrieveRec", "BUGLOG"));
          
        }

        public BaseApplicationPage Page
        {
            get {
                return ((BaseApplicationPage)base.Page);
            }
        }

#endregion

}

  
// Base class for the BugsSummaryTableControl1 control on the ShowBugsSummaryTablePage page.
// Do not modify this class. Instead override any method in BugsSummaryTableControl1.
public class BaseBugsSummaryTableControl1 : BUGLOG.UI.BaseApplicationTableControl
{
        public BaseBugsSummaryTableControl1()
        {
            this.Init += new EventHandler(Control_Init);
            this.Load += new EventHandler(Control_Load);
            this.PreRender += new EventHandler(Control_PreRender);
        }

        protected virtual void Control_Init(object sender, System.EventArgs e)
        {
            // Setup the pagination events.
        
              this.BugsSummaryPagination1.FirstPage.Click += new ImageClickEventHandler(BugsSummaryPagination1_FirstPage_Click);
              this.BugsSummaryPagination1.LastPage.Click += new ImageClickEventHandler(BugsSummaryPagination1_LastPage_Click);
              this.BugsSummaryPagination1.NextPage.Click += new ImageClickEventHandler(BugsSummaryPagination1_NextPage_Click);
              this.BugsSummaryPagination1.PageSizeButton.Click += new EventHandler(BugsSummaryPagination1_PageSizeButton_Click);
            
              this.BugsSummaryPagination1.PreviousPage.Click += new ImageClickEventHandler(BugsSummaryPagination1_PreviousPage_Click);

            // Setup the sorting events.
        
              this.AssignedLabel1.Click += new EventHandler(AssignedLabel1_Click);
            
              this.BugIdLabel1.Click += new EventHandler(BugIdLabel1_Click);
            
              this.BugShortDescriptionLabel1.Click += new EventHandler(BugShortDescriptionLabel1_Click);
            
              this.DateLabel1.Click += new EventHandler(DateLabel1_Click);
            
              this.DescriptionLabel1.Click += new EventHandler(DescriptionLabel1_Click);
            
              this.EnvBUGLOGmentLabel1.Click += new EventHandler(EnvBUGLOGmentLabel1_Click);
            
              this.FixedByLabel1.Click += new EventHandler(FixedByLabel1_Click);
            
              this.PriorityIDLabel3.Click += new EventHandler(PriorityIDLabel3_Click);
            
              this.StatusIDLabel1.Click += new EventHandler(StatusIDLabel1_Click);
            
              this.StepsToReproduceLabel1.Click += new EventHandler(StepsToReproduceLabel1_Click);
            
              this.TaskIDLabel2.Click += new EventHandler(TaskIDLabel2_Click);
            
              this.TestCaseIDLabel1.Click += new EventHandler(TestCaseIDLabel1_Click);
            
              this.userIDLabel3.Click += new EventHandler(userIDLabel3_Click);
            

            // Setup the button events.
        
              this.BugsSummaryCopyButton1.Click += new ImageClickEventHandler(BugsSummaryCopyButton1_Click);
              this.BugsSummaryDeleteButton1.Click += new ImageClickEventHandler(BugsSummaryDeleteButton1_Click);
              this.BugsSummaryEditButton1.Click += new ImageClickEventHandler(BugsSummaryEditButton1_Click);
              this.BugsSummaryExportButton1.Click += new ImageClickEventHandler(BugsSummaryExportButton1_Click);
                      this.Page.RegisterPostBackTrigger(MiscUtils.FindControlRecursively(this,"BugsSummaryExportButton1"), MiscUtils.GetParentControlObject(this,"BugsSummaryTableControl1UpdatePanel"));
                    
              this.BugsSummaryExportExcelButton1.Click += new ImageClickEventHandler(BugsSummaryExportExcelButton1_Click);
                      this.Page.RegisterPostBackTrigger(MiscUtils.FindControlRecursively(this,"BugsSummaryExportExcelButton1"), MiscUtils.GetParentControlObject(this,"BugsSummaryTableControl1UpdatePanel"));
                    
              this.BugsSummaryNewButton1.Click += new ImageClickEventHandler(BugsSummaryNewButton1_Click);
              this.BugsSummaryPDFButton1.Click += new ImageClickEventHandler(BugsSummaryPDFButton1_Click);
                      this.Page.RegisterPostBackTrigger(MiscUtils.FindControlRecursively(this,"BugsSummaryPDFButton1"), MiscUtils.GetParentControlObject(this,"BugsSummaryTableControl1UpdatePanel"));
                    
              this.BugsSummaryRefreshButton1.Click += new ImageClickEventHandler(BugsSummaryRefreshButton1_Click);
              this.BugsSummaryResetButton1.Click += new ImageClickEventHandler(BugsSummaryResetButton1_Click);
              this.BugsSummarySearchButton1.Button.Click += new EventHandler(BugsSummarySearchButton1_Click);

            // Setup the filter and search events.
        
            this.PriorityIDFilter1.SelectedIndexChanged += new EventHandler(PriorityIDFilter1_SelectedIndexChanged);
            this.StatusIDFilter.SelectedIndexChanged += new EventHandler(StatusIDFilter_SelectedIndexChanged);
            if (!this.Page.IsPostBack && this.InSession(this.BugsSummarySearchArea1)) {
                
                this.BugsSummarySearchArea1.Text = this.GetFromSession(this.BugsSummarySearchArea1);
            }
            if (!this.Page.IsPostBack && this.InSession(this.PriorityIDFilter1)) {
                this.PriorityIDFilter1.Items.Add(new ListItem(this.GetFromSession(this.PriorityIDFilter1), this.GetFromSession(this.PriorityIDFilter1)));
                this.PriorityIDFilter1.SelectedValue = this.GetFromSession(this.PriorityIDFilter1);
            }
            if (!this.Page.IsPostBack && this.InSession(this.StatusIDFilter)) {
                this.StatusIDFilter.Items.Add(new ListItem(this.GetFromSession(this.StatusIDFilter), this.GetFromSession(this.StatusIDFilter)));
                this.StatusIDFilter.SelectedValue = this.GetFromSession(this.StatusIDFilter);
            }

            // Control Initializations.
            // Initialize the table's current sort order.
            if (this.InSession(this, "Order_By")) {
                this.CurrentSortOrder = OrderBy.FromXmlString(this.GetFromSession(this, "Order_By", null));
            } else {
                this.CurrentSortOrder = new OrderBy(true, true);
        
                this.CurrentSortOrder.Add(BugsSummaryTable.BugId, OrderByItem.OrderDir.Asc);
        
                this.CurrentSortOrder.Add(BugsSummaryTable.Date0, OrderByItem.OrderDir.Asc);
        
            }

    // Setup default pagination settings.
    
            this.PageSize = Convert.ToInt32(this.GetFromSession(this, "Page_Size", "10"));
            this.PageIndex = Convert.ToInt32(this.GetFromSession(this, "Page_Index", "0"));
            this.ClearControlsFromSession();
        }

        protected virtual void Control_Load(object sender, EventArgs e)
        {
        
            SaveControlsToSession_Ajax();
        
                // Show confirmation message on Click
                this.BugsSummaryDeleteButton1.Attributes.Add("onClick", "return (confirm('" + ((BaseApplicationPage)this.Page).GetResourceValue("DeleteConfirm", "BUGLOG") + "'));");
        }

        // Read data from database. Returns an array of records that can be assigned
        // to the DataSource table control property.
        public virtual void LoadData()
        {
            try {
            
                // The WHERE clause will be empty when displaying all records in table.
                WhereClause wc = CreateWhereClause();
                if (wc != null && !wc.RunQuery) {
                    // Initialize an empty array of records
                    ArrayList alist = new ArrayList(0);
                    this.DataSource = (BugsSummaryRecord[])(alist.ToArray(Type.GetType("BUGLOG.Business.BugsSummaryRecord")));
                    return;
                }

                OrderBy orderBy = CreateOrderBy();

                // Get the pagesize from the pagesize control.
                this.GetPageSize();

                // Get the total number of records to be displayed.
                this.TotalRecords = BugsSummaryTable.GetRecordCount(wc);

                // Go to the last page.
                if (this.TotalPages <= 0 || this.PageIndex < 0) {
                    this.PageIndex = 0;
                } else if (this.DisplayLastPage || this.PageIndex >= this.TotalPages) {
                    this.PageIndex = this.TotalPages - 1;
                }

                // Retrieve the records and set the table DataSource.
                // Only PageSize records are fetched starting at PageIndex (zero based).
                if (this.TotalRecords <= 0) {
                    // Initialize an empty array of records
                    ArrayList alist = new ArrayList(0);
                    this.DataSource = (BugsSummaryRecord[])(alist.ToArray(Type.GetType("BUGLOG.Business.BugsSummaryRecord")));
                } else if (this.AddNewRecord > 0) {
                    // Get the records from the posted data
                    ArrayList postdata = new ArrayList(0);
                    foreach (BugsSummaryTableControl1Row rc in this.GetRecordControls()) {
                        if (!rc.IsNewRecord) {
                            rc.DataSource = rc.GetRecord();
                            rc.GetUIData();
                            postdata.Add(rc.DataSource);
                        }
                    }
                    this.DataSource = (BugsSummaryRecord[])(postdata.ToArray(Type.GetType("BUGLOG.Business.BugsSummaryRecord")));
                } else {
                    // Get the records from the database
                    this.DataSource = BugsSummaryTable.GetRecords(wc, orderBy, this.PageIndex, this.PageSize);
                }

                // Initialize the page and grand totals. now
            
            } catch (Exception ex) {
                throw ex;
            } finally {
                // Add records to the list.
                this.AddNewRecords();
            }
        }

        // Populate the UI controls.
        public override void DataBind()
        {
            base.DataBind();

            // Make sure that the DataSource is initialized.
            if (this.DataSource == null) {
                return;
            }
        
            // Improve performance by prefetching display as records.
            this.PreFetchForeignKeyValues();

            // Setup the pagination controls.
            BindPaginationControls();

            // Populate all filters data.
        
            this.PopulatePriorityIDFilter1(MiscUtils.GetSelectedValue(this.PriorityIDFilter1, this.GetFromSession(this.PriorityIDFilter1)), 500);
            this.PopulateStatusIDFilter(MiscUtils.GetSelectedValue(this.StatusIDFilter, this.GetFromSession(this.StatusIDFilter)), 500);

            // Bind the repeater with the list of records to expand the UI.
            System.Web.UI.WebControls.Repeater rep = (System.Web.UI.WebControls.Repeater)(this.FindControl("BugsSummaryTableControl1Repeater"));
            rep.DataSource = this.DataSource;
            rep.DataBind();

            int index = 0;
            foreach (System.Web.UI.WebControls.RepeaterItem repItem in rep.Items)
            {
                // Loop through all rows in the table, set its DataSource and call DataBind().
                BugsSummaryTableControl1Row recControl = (BugsSummaryTableControl1Row)(repItem.FindControl("BugsSummaryTableControl1Row"));
                recControl.DataSource = this.DataSource[index];
                recControl.DataBind();
                recControl.Visible = !this.InDeletedRecordIds(recControl);
                index += 1;
            }
        }

        
        public void PreFetchForeignKeyValues() {
            if (this.DataSource == null) {
                return;
            }
          
            this.Page.PregetDfkaRecords(BugsSummaryTable.Assigned, this.DataSource);
            this.Page.PregetDfkaRecords(BugsSummaryTable.FixedBy, this.DataSource);
            this.Page.PregetDfkaRecords(BugsSummaryTable.PriorityID, this.DataSource);
            this.Page.PregetDfkaRecords(BugsSummaryTable.StatusID, this.DataSource);
            this.Page.PregetDfkaRecords(BugsSummaryTable.TaskID, this.DataSource);
            this.Page.PregetDfkaRecords(BugsSummaryTable.TestCaseID, this.DataSource);
            this.Page.PregetDfkaRecords(BugsSummaryTable.UserId0, this.DataSource);
        }
         

        protected virtual void BindPaginationControls()
        {
            // Setup the pagination controls.

            // Bind the buttons for BugsSummaryTableControl1 pagination.
        
            this.BugsSummaryPagination1.FirstPage.Enabled = !(this.PageIndex == 0);
            this.BugsSummaryPagination1.LastPage.Enabled = !(this.PageIndex == this.TotalPages - 1);
            if (this.TotalPages == 0) {
                this.BugsSummaryPagination1.LastPage.Enabled = false;
            }
          
            this.BugsSummaryPagination1.NextPage.Enabled = !(this.PageIndex == this.TotalPages - 1);
            if (this.TotalPages == 0) {
                this.BugsSummaryPagination1.NextPage.Enabled = false;
            }
          
            this.BugsSummaryPagination1.PreviousPage.Enabled = !(this.PageIndex == 0);

            // Bind the pagination labels.
        
            if (this.TotalPages > 0) {
                this.BugsSummaryPagination1.CurrentPage.Text = (this.PageIndex + 1).ToString();
            } else {
                this.BugsSummaryPagination1.CurrentPage.Text = "0";
            }
            this.BugsSummaryPagination1.PageSize.Text = this.PageSize.ToString();
            this.BugsSummaryTotalItems1.Text = this.TotalRecords.ToString();
            this.BugsSummaryPagination1.TotalItems.Text = this.TotalRecords.ToString();
            this.BugsSummaryPagination1.TotalPages.Text = this.TotalPages.ToString();
        }

        public virtual void SaveData()
        {
            foreach (BugsSummaryTableControl1Row recCtl in this.GetRecordControls())
            {
        
                if (this.InDeletedRecordIds(recCtl)) {
                    recCtl.Delete();
                } else {
                    if (recCtl.Visible) {
                        recCtl.SaveData();
                    }
                }
          
            }
            
            this.DataChanged = true;
            this.ResetData = true;
        }

        public virtual OrderBy CreateOrderBy()
        {
            return this.CurrentSortOrder;
        }

        // This CreateWhereClause is used for loading the data.
        public virtual WhereClause CreateWhereClause()
        {
            BugsSummaryTable.Instance.InnerFilter = null;
            WhereClause wc = new WhereClause();
            // CreateWhereClause() Compose the WHERE clause consiting of:
            // 1. Static clause defined at design time.
            // 2. User selected filter criteria.
            // 3. User selected search criteria.
        
            if (MiscUtils.IsValueSelected(this.BugsSummarySearchArea1)) {
                // Strip "..." from begin and ending of the search text, otherwise the search will return 0 values as in database "..." is not stored.
                if (this.BugsSummarySearchArea1.Text.StartsWith("...")) {
                    this.BugsSummarySearchArea1.Text = this.BugsSummarySearchArea1.Text.Substring(3,this.BugsSummarySearchArea1.Text.Length-3);
                }
                if (this.BugsSummarySearchArea1.Text.EndsWith("...")) {
                    this.BugsSummarySearchArea1.Text = this.BugsSummarySearchArea1.Text.Substring(0,this.BugsSummarySearchArea1.Text.Length-3);
                }
                // After stripping "..." see if the search text is null or empty.
                if (MiscUtils.IsValueSelected(this.BugsSummarySearchArea1)) {
                      
                    // These clauses are added depending on operator and fields selected in Control's property page, bindings tab.
                    WhereClause search = new WhereClause();
                    
                    search.iOR(BugsSummaryTable.BugId, BaseFilter.ComparisonOperator.Contains, MiscUtils.GetSelectedValue(this.BugsSummarySearchArea1, this.GetFromSession(this.BugsSummarySearchArea1)), true, false);
        
                    search.iOR(BugsSummaryTable.Description, BaseFilter.ComparisonOperator.Contains, MiscUtils.GetSelectedValue(this.BugsSummarySearchArea1, this.GetFromSession(this.BugsSummarySearchArea1)), true, false);
        
                    search.iOR(BugsSummaryTable.StepsToReproduce, BaseFilter.ComparisonOperator.Contains, MiscUtils.GetSelectedValue(this.BugsSummarySearchArea1, this.GetFromSession(this.BugsSummarySearchArea1)), true, false);
        
                    search.iOR(BugsSummaryTable.Note, BaseFilter.ComparisonOperator.Contains, MiscUtils.GetSelectedValue(this.BugsSummarySearchArea1, this.GetFromSession(this.BugsSummarySearchArea1)), true, false);
        
                    search.iOR(BugsSummaryTable.TestCaseID, BaseFilter.ComparisonOperator.Contains, MiscUtils.GetSelectedValue(this.BugsSummarySearchArea1, this.GetFromSession(this.BugsSummarySearchArea1)), true, false);
        
                    search.iOR(BugsSummaryTable.TaskID, BaseFilter.ComparisonOperator.Contains, MiscUtils.GetSelectedValue(this.BugsSummarySearchArea1, this.GetFromSession(this.BugsSummarySearchArea1)), true, false);
        
                    wc.iAND(search);
                }
            }
                  
            if (MiscUtils.IsValueSelected(this.PriorityIDFilter1)) {
                wc.iAND(BugsSummaryTable.PriorityID, BaseFilter.ComparisonOperator.EqualsTo, MiscUtils.GetSelectedValue(this.PriorityIDFilter1, this.GetFromSession(this.PriorityIDFilter1)), false, false);
            }
                      
            if (MiscUtils.IsValueSelected(this.StatusIDFilter)) {
                wc.iAND(BugsSummaryTable.StatusID, BaseFilter.ComparisonOperator.EqualsTo, MiscUtils.GetSelectedValue(this.StatusIDFilter, this.GetFromSession(this.StatusIDFilter)), false, false);
            }
                      
            return (wc);
        }
        
         
        // This CreateWhereClause is used for loading list of suggestions for Auto Type-Ahead feature.
        public virtual WhereClause CreateWhereClause(String searchText, String fromSearchControl, String AutoTypeAheadSearch, String AutoTypeAheadWordSeparators)
        {
            BugsSummaryTable.Instance.InnerFilter = null;
            WhereClause wc= new WhereClause();
            // Compose the WHERE clause consiting of:
            // 1. Static clause defined at design time.
            // 2. User selected filter criteria.
            // 3. User selected search criteria.
            String appRelativeVirtualPath = (String)HttpContext.Current.Session["AppRelatvieVirtualPath"];
          
            // Adds clauses if values are selected in Filter controls which are configured in the page.
          
            if (MiscUtils.IsValueSelected(searchText) && fromSearchControl == "BugsSummarySearchArea1") {
                String formatedSearchText = searchText;
                // strip "..." from begin and ending of the search text, otherwise the search will return 0 values as in database "..." is not stored.
                if (searchText.StartsWith("...")) {
                    formatedSearchText = searchText.Substring(3,searchText.Length-3);
                }
                if (searchText.EndsWith("...")) {
                    formatedSearchText = searchText.Substring(0,searchText.Length-3);
                }
                // After stripping "...", trim any leading and trailing whitespaces 
                formatedSearchText = formatedSearchText.Trim();
                // After stripping "..." see if the search text is null or empty.
                if (MiscUtils.IsValueSelected(searchText)) {
                      
                    // These clauses are added depending on operator and fields selected in Control's property page, bindings tab.
                    WhereClause search = new WhereClause();
                    
                    if (StringUtils.InvariantLCase(AutoTypeAheadSearch).Equals("wordsstartingwithsearchstring")) {
                
                        search.iOR(BugsSummaryTable.BugId, BaseFilter.ComparisonOperator.Starts_With, formatedSearchText, true, false);
                        search.iOR(BugsSummaryTable.BugId, BaseFilter.ComparisonOperator.Contains, AutoTypeAheadWordSeparators + formatedSearchText, true, false);
                  
                
                        search.iOR(BugsSummaryTable.Description, BaseFilter.ComparisonOperator.Starts_With, formatedSearchText, true, false);
                        search.iOR(BugsSummaryTable.Description, BaseFilter.ComparisonOperator.Contains, AutoTypeAheadWordSeparators + formatedSearchText, true, false);
                  
                
                        search.iOR(BugsSummaryTable.StepsToReproduce, BaseFilter.ComparisonOperator.Starts_With, formatedSearchText, true, false);
                        search.iOR(BugsSummaryTable.StepsToReproduce, BaseFilter.ComparisonOperator.Contains, AutoTypeAheadWordSeparators + formatedSearchText, true, false);
                  
                
                        search.iOR(BugsSummaryTable.Note, BaseFilter.ComparisonOperator.Starts_With, formatedSearchText, true, false);
                        search.iOR(BugsSummaryTable.Note, BaseFilter.ComparisonOperator.Contains, AutoTypeAheadWordSeparators + formatedSearchText, true, false);
                  
                
                        search.iOR(BugsSummaryTable.TestCaseID, BaseFilter.ComparisonOperator.Starts_With, formatedSearchText, true, false);
                        search.iOR(BugsSummaryTable.TestCaseID, BaseFilter.ComparisonOperator.Contains, AutoTypeAheadWordSeparators + formatedSearchText, true, false);
                  
                
                        search.iOR(BugsSummaryTable.TaskID, BaseFilter.ComparisonOperator.Starts_With, formatedSearchText, true, false);
                        search.iOR(BugsSummaryTable.TaskID, BaseFilter.ComparisonOperator.Contains, AutoTypeAheadWordSeparators + formatedSearchText, true, false);
                  
                
                    } else {
                        
                        search.iOR(BugsSummaryTable.BugId, BaseFilter.ComparisonOperator.Contains, formatedSearchText, true, false);
                        search.iOR(BugsSummaryTable.Description, BaseFilter.ComparisonOperator.Contains, formatedSearchText, true, false);
                        search.iOR(BugsSummaryTable.StepsToReproduce, BaseFilter.ComparisonOperator.Contains, formatedSearchText, true, false);
                        search.iOR(BugsSummaryTable.Note, BaseFilter.ComparisonOperator.Contains, formatedSearchText, true, false);
                        search.iOR(BugsSummaryTable.TestCaseID, BaseFilter.ComparisonOperator.Contains, formatedSearchText, true, false);
                        search.iOR(BugsSummaryTable.TaskID, BaseFilter.ComparisonOperator.Contains, formatedSearchText, true, false);
                    } 
                    wc.iAND(search);
                }
            }
                  
            String PriorityIDFilter1SelectedValue = (String)HttpContext.Current.Session[HttpContext.Current.Session.SessionID + appRelativeVirtualPath + "PriorityIDFilter1_Ajax"];
            if (MiscUtils.IsValueSelected(PriorityIDFilter1SelectedValue)) {
                wc.iAND(BugsSummaryTable.PriorityID, BaseFilter.ComparisonOperator.EqualsTo, PriorityIDFilter1SelectedValue, false, false);
            }
                      
            String StatusIDFilterSelectedValue = (String)HttpContext.Current.Session[HttpContext.Current.Session.SessionID + appRelativeVirtualPath + "StatusIDFilter_Ajax"];
            if (MiscUtils.IsValueSelected(StatusIDFilterSelectedValue)) {
                wc.iAND(BugsSummaryTable.StatusID, BaseFilter.ComparisonOperator.EqualsTo, StatusIDFilterSelectedValue, false, false);
            }
                      
            return wc;
        }
          
         public virtual string[] GetAutoCompletionList_BugsSummarySearchArea1(String prefixText,int count)
         {
            ArrayList resultList = new ArrayList();
            ArrayList wordList= new ArrayList();
            int iteration = 0;
            
            WhereClause wc= CreateWhereClause(prefixText,"BugsSummarySearchArea1", "WordsStartingWithSearchString", "[^a-zA-Z0-9]");
            while (resultList.Count < count && iteration < 5){
                // Fetch 100 records in each iteration
                BUGLOG.Business.BugsSummaryRecord[] records = BugsSummaryTable.GetRecords(wc, null, iteration, 100);
                String resultItem = "";
                foreach (BugsSummaryRecord rec in records){
                    // Exit the loop if recordList count has reached AutoTypeAheadListSize.
                    if (resultList.Count >= count) {
                        break;
                    }
                    // If the field is configured to Display as Foreign key, Format() method returns the 
                    // Display as Forien Key value instead of original field value.
                    // Since search had to be done in multiple fields (selected in Control's page property, binding tab) in a record,
                    // We need to find relevent field to display which matches the prefixText and is not already present in the result list.
            
                    resultItem = rec.Format(BugsSummaryTable.BugId);
                    if (StringUtils.InvariantUCase(resultItem).Contains(StringUtils.InvariantUCase(prefixText))) {
                        bool isAdded = FormatSuggestions(prefixText, resultItem, 50, "AtBeginningOfMatchedString", "WordsStartingWithSearchString", "[^a-zA-Z0-9]", resultList);
                        if (isAdded) {
                            continue;
                        }
                    }
      
                    resultItem = rec.Format(BugsSummaryTable.Description);
                    if (StringUtils.InvariantUCase(resultItem).Contains(StringUtils.InvariantUCase(prefixText))) {
                        bool isAdded = FormatSuggestions(prefixText, resultItem, 50, "AtBeginningOfMatchedString", "WordsStartingWithSearchString", "[^a-zA-Z0-9]", resultList);
                        if (isAdded) {
                            continue;
                        }
                    }
      
                    resultItem = rec.Format(BugsSummaryTable.StepsToReproduce);
                    if (StringUtils.InvariantUCase(resultItem).Contains(StringUtils.InvariantUCase(prefixText))) {
                        bool isAdded = FormatSuggestions(prefixText, resultItem, 50, "AtBeginningOfMatchedString", "WordsStartingWithSearchString", "[^a-zA-Z0-9]", resultList);
                        if (isAdded) {
                            continue;
                        }
                    }
      
                    resultItem = rec.Format(BugsSummaryTable.Note);
                    if (StringUtils.InvariantUCase(resultItem).Contains(StringUtils.InvariantUCase(prefixText))) {
                        bool isAdded = FormatSuggestions(prefixText, resultItem, 50, "AtBeginningOfMatchedString", "WordsStartingWithSearchString", "[^a-zA-Z0-9]", resultList);
                        if (isAdded) {
                            continue;
                        }
                    }
      
                    resultItem = rec.Format(BugsSummaryTable.TestCaseID);
                    if (StringUtils.InvariantUCase(resultItem).Contains(StringUtils.InvariantUCase(prefixText))) {
                        bool isAdded = FormatSuggestions(prefixText, resultItem, 50, "AtBeginningOfMatchedString", "WordsStartingWithSearchString", "[^a-zA-Z0-9]", resultList);
                        if (isAdded) {
                            continue;
                        }
                    }
      
                    resultItem = rec.Format(BugsSummaryTable.TaskID);
                    if (StringUtils.InvariantUCase(resultItem).Contains(StringUtils.InvariantUCase(prefixText))) {
                        bool isAdded = FormatSuggestions(prefixText, resultItem, 50, "AtBeginningOfMatchedString", "WordsStartingWithSearchString", "[^a-zA-Z0-9]", resultList);
                        if (isAdded) {
                            continue;
                        }
                    }
      
                }
                // Exit the loop if number of records found is less as further iteration will not return any more records
                if (records.Length < 100 ) {
                    break;
                }
                iteration++;
            }
            resultList.Sort();
            string[] result = new string[resultList.Count];
            Array.Copy(resultList.ToArray(), result, resultList.Count);
            return result;
        }
          
        // Formats the result Item and adds it to the list of suggestions.
        public virtual bool FormatSuggestions(String prefixText, String resultItem,
                                              int columnLength, String AutoTypeAheadDisplayFoundText,
                                              String autoTypeAheadSearch, String AutoTypeAheadWordSeparators,
                                              ArrayList resultList)
        {
              int index  = StringUtils.InvariantLCase(resultItem).IndexOf(StringUtils.InvariantLCase(prefixText));
            String itemToAdd = null;
            bool isFound = false;
            bool isAdded = false;
            if (StringUtils.InvariantLCase(autoTypeAheadSearch).Equals("wordsstartingwithsearchstring") && !(index == 0)) {
                 // Expression to find word which contains AutoTypeAheadWordSeparators followed by prefixText
                System.Text.RegularExpressions.Regex regex1 = new System.Text.RegularExpressions.Regex( AutoTypeAheadWordSeparators + prefixText, System.Text.RegularExpressions.RegexOptions.IgnoreCase);
                if (regex1.IsMatch(resultItem)) {
                    index = regex1.Match(resultItem).Index;
                    isFound = true;
                }
                //If the prefixText is found immediatly after white space then starting of the word is found so don not search any further
                if (resultItem[index].ToString() != " ") {
                    // Expression to find beginning of the word which contains AutoTypeAheadWordSeparators followed by prefixText
                    System.Text.RegularExpressions.Regex regex = new System.Text.RegularExpressions.Regex("\\S*" + AutoTypeAheadWordSeparators + prefixText, System.Text.RegularExpressions.RegexOptions.IgnoreCase);
                    if (regex.IsMatch(resultItem)) {
                        index = regex.Match(resultItem).Index;
                        isFound = true;
                    }
                }
            }
            // If autoTypeAheadSearch value is wordsstartingwithsearchstring then, extract the substring only if the prefixText is found at the 
            // beginning of the resultItem (index = 0) or a word in resultItem is found starts with prefixText. 
            if (index == 0 || isFound || StringUtils.InvariantLCase(autoTypeAheadSearch).Equals("anywhereinstring")) {
                if (StringUtils.InvariantLCase(AutoTypeAheadDisplayFoundText).Equals("atbeginningofmatchedstring")) {
                    // Expression to find beginning of the word which contains prefixText
                    System.Text.RegularExpressions.Regex regex1 = new System.Text.RegularExpressions.Regex("\\S*" + prefixText, System.Text.RegularExpressions.RegexOptions.IgnoreCase);
                    //  Find the beginning of the word which contains prefexText
                    if (StringUtils.InvariantLCase(autoTypeAheadSearch).Equals("anywhereinstring") && regex1.IsMatch(resultItem)) {
                        index = regex1.Match(resultItem).Index;
                        isFound = true;
                    }
                    // Display string from the index till end of the string if, sub string from index till end of string is less than columnLength value.
                    if ((resultItem.Length - index) <= columnLength) {
                        if (index == 0) {
                            itemToAdd = resultItem;
                        } else {
                            itemToAdd = "..." + resultItem.Substring(index, resultItem.Length - index);
                        }
                    } else {
                        if (index == 0) {
                          itemToAdd = resultItem.Substring(index, (columnLength - 3)) + "...";
                        } else {
                            // Truncate the string to show only columnLength - 6 characters as begining and trailing "..." has to be appended.
                            itemToAdd = "..." + resultItem.Substring(index, (columnLength - 6)) + "...";
                        }
                    }
                } else if (StringUtils.InvariantLCase(AutoTypeAheadDisplayFoundText).Equals("inmiddleofmatchedstring")) {
                    int subStringBeginIndex = (int)(columnLength / 2);
                    if (resultItem.Length <= columnLength) {
                        itemToAdd = resultItem;
                    } else {
                        // Sanity check at end of the string
                        if ((index + prefixText.Length) == columnLength) {
                            itemToAdd = "..." + resultItem.Substring((index - columnLength), index);
                        } else if ((resultItem.Length - index) < subStringBeginIndex) {
                            //  Display string from the end till columnLength value if, index is closer to the end of the string.
                            itemToAdd = "..." + resultItem.Substring(resultItem.Length - columnLength, resultItem.Length);
                        } else if (index <= subStringBeginIndex) {
                            // Sanity chet at beginning of the string
                            itemToAdd = resultItem.Substring(0, columnLength) + "...";
                        } else {
                            // Display string containing text before the prefixText occures and text after the prefixText
                            itemToAdd = "..." + resultItem.Substring(index - subStringBeginIndex, columnLength) + "...";
                        }
                    }
                } else if (StringUtils.InvariantLCase(AutoTypeAheadDisplayFoundText).Equals("atendofmatchedstring")) {
                     // Expression to find ending of the word which contains prefexText
                    System.Text.RegularExpressions.Regex regex1 = new System.Text.RegularExpressions.Regex("\\s", System.Text.RegularExpressions.RegexOptions.IgnoreCase); 
                    // Find the ending of the word which contains prefexText
                    if (regex1.IsMatch(resultItem, index + 1)) {
                        index = regex1.Match(resultItem, index + 1).Index;
                    }else{
                        // If the word which contains prefexText is the last word in string, regex1.IsMatch returns false.
                        index = resultItem.Length;
                    }
                    
                    if (index > resultItem.Length) {
                        index = resultItem.Length;
                    }
                    // If text from beginning of the string till index is less than columnLength value then, display string from the beginning till index.
                    if (index <= columnLength) {
                        if (index == resultItem.Length) {   //Make decision to append "..."
                            itemToAdd = resultItem.Substring(0, index);
                        } else {
                            itemToAdd = resultItem.Substring(0, index) + "...";
                        }
                    } else if (index == resultItem.Length) {
                        itemToAdd = "..." + resultItem.Substring(index - (columnLength - 3), columnLength - 3);
                    } else {
                        // Truncate the string to show only columnLength - 6 characters as begining and trailing "..." has to be appended.
                        itemToAdd = "..." + resultItem.Substring(index - (columnLength - 6), (columnLength - 6)) + "...";
                    }
                }
                
                // Remove newline character from itemToAdd
                int prefixTextIndex = itemToAdd.IndexOf(prefixText, StringComparison.InvariantCultureIgnoreCase);
                // If itemToAdd contains any newline after the search text then show text only till newline
                System.Text.RegularExpressions.Regex regex2 = new System.Text.RegularExpressions.Regex("(\r\n|\n)", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
                int newLineIndexAfterPrefix = -1;
                if (regex2.IsMatch(itemToAdd, prefixTextIndex)){
                    newLineIndexAfterPrefix = regex2.Match(itemToAdd, prefixTextIndex).Index;
                }
                if ((newLineIndexAfterPrefix > -1)) {
                    if (itemToAdd.EndsWith("...")) {
                        itemToAdd = itemToAdd.Substring(0, newLineIndexAfterPrefix) + "...";
                    }
                    else {
                        itemToAdd = itemToAdd.Substring(0, newLineIndexAfterPrefix);
                    }
                }
                // If itemToAdd contains any newline before search text then show text which comes after newline
                System.Text.RegularExpressions.Regex regex3 = new System.Text.RegularExpressions.Regex("(\r\n|\n)", System.Text.RegularExpressions.RegexOptions.IgnoreCase | System.Text.RegularExpressions.RegexOptions.RightToLeft );
                int newLineIndexBeforePrefix = -1;
                if (regex3.IsMatch(itemToAdd, prefixTextIndex)){
                    newLineIndexBeforePrefix = regex3.Match(itemToAdd, prefixTextIndex).Index;
                }
                if ((newLineIndexBeforePrefix > -1)) {
                    if (itemToAdd.StartsWith("...")) {
                        itemToAdd = "..." + itemToAdd.Substring(newLineIndexBeforePrefix +regex3.Match(itemToAdd, prefixTextIndex).Length);
                    }
                    else {
                        itemToAdd = itemToAdd.Substring(newLineIndexBeforePrefix +regex3.Match(itemToAdd, prefixTextIndex).Length);
                    }
                }

                if (itemToAdd!= null && !resultList.Contains(itemToAdd)) {
                    resultList.Add(itemToAdd);
                    isAdded = true;
                }
            }
            return isAdded;
        }
        
        
    
        protected virtual void GetPageSize()
        {
        
            if (this.BugsSummaryPagination1.PageSize.Text.Length > 0) {
                try {
                    // this.PageSize = Convert.ToInt32(this.BugsSummaryPagination1.PageSize.Text);
                } catch (Exception ex) {
                }
            }
        }

        protected virtual void AddNewRecords()
        {
            ArrayList newRecordList = new ArrayList();

            // Loop though all the record controls and if the record control
            // does not have a unique record id set, then create a record
            // and add to the list.
            if (!this.ResetData)
            {
                System.Web.UI.WebControls.Repeater rep = (System.Web.UI.WebControls.Repeater)(this.FindControl("BugsSummaryTableControl1Repeater"));
                int index = 0;

                foreach (System.Web.UI.WebControls.RepeaterItem repItem in rep.Items)
                {
                    // Loop through all rows in the table, set its DataSource and call DataBind().
                    BugsSummaryTableControl1Row recControl = (BugsSummaryTableControl1Row)(repItem.FindControl("BugsSummaryTableControl1Row"));

                    if (recControl.Visible && recControl.IsNewRecord) {
                        BugsSummaryRecord rec = new BugsSummaryRecord();
        
                        if (recControl.Assigned1.Text != "") {
                            rec.Parse(recControl.Assigned1.Text, BugsSummaryTable.Assigned);
                        }
                        if (recControl.BugId1.Text != "") {
                            rec.Parse(recControl.BugId1.Text, BugsSummaryTable.BugId);
                        }
                        if (recControl.BugShortDescription1.Text != "") {
                            rec.Parse(recControl.BugShortDescription1.Text, BugsSummaryTable.BugShortDescription);
                        }
                        if (recControl.Date2.Text != "") {
                            rec.Parse(recControl.Date2.Text, BugsSummaryTable.Date0);
                        }
                        if (recControl.Description1.Text != "") {
                            rec.Parse(recControl.Description1.Text, BugsSummaryTable.Description);
                        }
                        if (recControl.EnvBUGLOGment1.Text != "") {
                            rec.Parse(recControl.EnvBUGLOGment1.Text, BugsSummaryTable.EnvBUGLOGment);
                        }
                        if (recControl.FixedBy1.Text != "") {
                            rec.Parse(recControl.FixedBy1.Text, BugsSummaryTable.FixedBy);
                        }
                        if (recControl.Note1.Text != "") {
                            rec.Parse(recControl.Note1.Text, BugsSummaryTable.Note);
                        }
                        if (recControl.PriorityID1.Text != "") {
                            rec.Parse(recControl.PriorityID1.Text, BugsSummaryTable.PriorityID);
                        }
                        if (recControl.StatusID1.Text != "") {
                            rec.Parse(recControl.StatusID1.Text, BugsSummaryTable.StatusID);
                        }
                        if (recControl.StepsToReproduce1.Text != "") {
                            rec.Parse(recControl.StepsToReproduce1.Text, BugsSummaryTable.StepsToReproduce);
                        }
                        if (recControl.TaskID1.Text != "") {
                            rec.Parse(recControl.TaskID1.Text, BugsSummaryTable.TaskID);
                        }
                        if (recControl.TestCaseID1.Text != "") {
                            rec.Parse(recControl.TestCaseID1.Text, BugsSummaryTable.TestCaseID);
                        }
                        if (recControl.UserId2.Text != "") {
                            rec.Parse(recControl.UserId2.Text, BugsSummaryTable.UserId0);
                        }
                        newRecordList.Add(rec);
                    }
                }
            }

            // Add any new record to the list.
            for (int count = 1; count <= this.AddNewRecord; count++) {
                newRecordList.Insert(0, new BugsSummaryRecord());
            }
            this.AddNewRecord = 0;

            // Finally , add any new records to the DataSource.
            if (newRecordList.Count > 0) {
                ArrayList finalList = new ArrayList(this.DataSource);
                finalList.InsertRange(0, newRecordList);

                this.DataSource = (BugsSummaryRecord[])(finalList.ToArray(Type.GetType("BUGLOG.Business.BugsSummaryRecord")));
            }
        }

        
        public void AddToDeletedRecordIds(BugsSummaryTableControl1Row rec)
        {
            if (rec.IsNewRecord) {
                return;
            }

            if (this.DeletedRecordIds != null && this.DeletedRecordIds.Length > 0) {
                this.DeletedRecordIds += ",";
            }

            this.DeletedRecordIds += "[" + rec.RecordUniqueId + "]";
        }

        private bool InDeletedRecordIds(BugsSummaryTableControl1Row rec)            
        {
            if (this.DeletedRecordIds == null || this.DeletedRecordIds.Length == 0) {
                return (false);
            }

            return (this.DeletedRecordIds.IndexOf("[" + rec.RecordUniqueId + "]") >= 0);
        }

        private String _DeletedRecordIds;
        public String DeletedRecordIds {
            get {
                return (this._DeletedRecordIds);
            }
            set {
                this._DeletedRecordIds = value;
            }
        }
        
        // Get the filters' data for PriorityIDFilter1.
        protected virtual void PopulatePriorityIDFilter1(string selectedValue, int maxItems)
        {
              
            //Setup the WHERE clause.
            WhereClause wc = new WhereClause();
            OrderBy orderBy = new OrderBy(false, true);
            orderBy.Add(PriorityLevelTable.PriorityLevel, OrderByItem.OrderDir.Asc);

            string noValueFormat = Page.GetResourceValue("Txt:Other", "BUGLOG");

            this.PriorityIDFilter1.Items.Clear();
            foreach (PriorityLevelRecord itemValue in PriorityLevelTable.GetRecords(wc, orderBy, 0, maxItems))
            {
                // Create the item and add to the list.
                string cvalue = null;
                string fvalue = noValueFormat;
                if (itemValue.PriorityIDSpecified) {
                    cvalue = itemValue.PriorityID.ToString();
                    fvalue = itemValue.Format(PriorityLevelTable.PriorityLevel);
                }

                ListItem item = new ListItem(fvalue, cvalue);
                if (this.PriorityIDFilter1.Items.IndexOf(item) < 0) {
                    this.PriorityIDFilter1.Items.Add(item);
                }
            }
                
            // Set the selected value.
            MiscUtils.SetSelectedValue(this.PriorityIDFilter1, selectedValue);

            // Add the All item.
            this.PriorityIDFilter1.Items.Insert(0, new ListItem(Page.GetResourceValue("Txt:All", "BUGLOG"), "--ANY--"));
        }
            
        // Get the filters' data for StatusIDFilter.
        protected virtual void PopulateStatusIDFilter(string selectedValue, int maxItems)
        {
              
            //Setup the WHERE clause.
            WhereClause wc = new WhereClause();
            OrderBy orderBy = new OrderBy(false, true);
            orderBy.Add(StatusTable.Status, OrderByItem.OrderDir.Asc);

            string noValueFormat = Page.GetResourceValue("Txt:Other", "BUGLOG");

            this.StatusIDFilter.Items.Clear();
            foreach (StatusRecord itemValue in StatusTable.GetRecords(wc, orderBy, 0, maxItems))
            {
                // Create the item and add to the list.
                string cvalue = null;
                string fvalue = noValueFormat;
                if (itemValue.StatusIDSpecified) {
                    cvalue = itemValue.StatusID.ToString();
                    fvalue = itemValue.Format(StatusTable.Status);
                }

                ListItem item = new ListItem(fvalue, cvalue);
                if (this.StatusIDFilter.Items.IndexOf(item) < 0) {
                    this.StatusIDFilter.Items.Add(item);
                }
            }
                
            // Set the selected value.
            MiscUtils.SetSelectedValue(this.StatusIDFilter, selectedValue);

            // Add the All item.
            this.StatusIDFilter.Items.Insert(0, new ListItem(Page.GetResourceValue("Txt:All", "BUGLOG"), "--ANY--"));
        }
                          
        // Create a where clause for the filter BugsSummarySearchArea1.
        public virtual WhereClause CreateWhereClause_BugsSummarySearchArea1()
        {
              
            WhereClause wc = new WhereClause();
                  
            if (MiscUtils.IsValueSelected(this.PriorityIDFilter1)) {
                wc.iAND(BugsSummaryTable.PriorityID, BaseFilter.ComparisonOperator.EqualsTo, MiscUtils.GetSelectedValue(this.PriorityIDFilter1, this.GetFromSession(this.PriorityIDFilter1)), false, false);
            }
                      
            if (MiscUtils.IsValueSelected(this.StatusIDFilter)) {
                wc.iAND(BugsSummaryTable.StatusID, BaseFilter.ComparisonOperator.EqualsTo, MiscUtils.GetSelectedValue(this.StatusIDFilter, this.GetFromSession(this.StatusIDFilter)), false, false);
            }
                      
            return wc;
        }
                          
        // Create a where clause for the filter PriorityIDFilter1.
        public virtual WhereClause CreateWhereClause_PriorityIDFilter1()
        {
              
            WhereClause wc = new WhereClause();
                  
            if (MiscUtils.IsValueSelected(this.BugsSummarySearchArea1)) {
                // Strip "..." from begin and ending of the search text, otherwise the search will return 0 values as in database "..." is not stored.
                if (this.BugsSummarySearchArea1.Text.StartsWith("...")) {
                    this.BugsSummarySearchArea1.Text = this.BugsSummarySearchArea1.Text.Substring(3,this.BugsSummarySearchArea1.Text.Length-3);
                }
                if (this.BugsSummarySearchArea1.Text.EndsWith("...")) {
                    this.BugsSummarySearchArea1.Text = this.BugsSummarySearchArea1.Text.Substring(0,this.BugsSummarySearchArea1.Text.Length-3);
                }
                // After stripping "..." see if the search text is null or empty.
                if (MiscUtils.IsValueSelected(this.BugsSummarySearchArea1)) {
                      
                    // These clauses are added depending on operator and fields selected in Control's property page, bindings tab.
                    WhereClause search = new WhereClause();
                    
                    search.iOR(BugsSummaryTable.BugId, BaseFilter.ComparisonOperator.Contains, MiscUtils.GetSelectedValue(this.BugsSummarySearchArea1, this.GetFromSession(this.BugsSummarySearchArea1)), true, false);
        
                    search.iOR(BugsSummaryTable.Description, BaseFilter.ComparisonOperator.Contains, MiscUtils.GetSelectedValue(this.BugsSummarySearchArea1, this.GetFromSession(this.BugsSummarySearchArea1)), true, false);
        
                    search.iOR(BugsSummaryTable.StepsToReproduce, BaseFilter.ComparisonOperator.Contains, MiscUtils.GetSelectedValue(this.BugsSummarySearchArea1, this.GetFromSession(this.BugsSummarySearchArea1)), true, false);
        
                    search.iOR(BugsSummaryTable.Note, BaseFilter.ComparisonOperator.Contains, MiscUtils.GetSelectedValue(this.BugsSummarySearchArea1, this.GetFromSession(this.BugsSummarySearchArea1)), true, false);
        
                    search.iOR(BugsSummaryTable.TestCaseID, BaseFilter.ComparisonOperator.Contains, MiscUtils.GetSelectedValue(this.BugsSummarySearchArea1, this.GetFromSession(this.BugsSummarySearchArea1)), true, false);
        
                    search.iOR(BugsSummaryTable.TaskID, BaseFilter.ComparisonOperator.Contains, MiscUtils.GetSelectedValue(this.BugsSummarySearchArea1, this.GetFromSession(this.BugsSummarySearchArea1)), true, false);
        
                    wc.iAND(search);
                }
            }
                  
            if (MiscUtils.IsValueSelected(this.StatusIDFilter)) {
                wc.iAND(BugsSummaryTable.StatusID, BaseFilter.ComparisonOperator.EqualsTo, MiscUtils.GetSelectedValue(this.StatusIDFilter, this.GetFromSession(this.StatusIDFilter)), false, false);
            }
                      
            return wc;
        }
                          
        // Create a where clause for the filter StatusIDFilter.
        public virtual WhereClause CreateWhereClause_StatusIDFilter()
        {
              
            WhereClause wc = new WhereClause();
                  
            if (MiscUtils.IsValueSelected(this.BugsSummarySearchArea1)) {
                // Strip "..." from begin and ending of the search text, otherwise the search will return 0 values as in database "..." is not stored.
                if (this.BugsSummarySearchArea1.Text.StartsWith("...")) {
                    this.BugsSummarySearchArea1.Text = this.BugsSummarySearchArea1.Text.Substring(3,this.BugsSummarySearchArea1.Text.Length-3);
                }
                if (this.BugsSummarySearchArea1.Text.EndsWith("...")) {
                    this.BugsSummarySearchArea1.Text = this.BugsSummarySearchArea1.Text.Substring(0,this.BugsSummarySearchArea1.Text.Length-3);
                }
                // After stripping "..." see if the search text is null or empty.
                if (MiscUtils.IsValueSelected(this.BugsSummarySearchArea1)) {
                      
                    // These clauses are added depending on operator and fields selected in Control's property page, bindings tab.
                    WhereClause search = new WhereClause();
                    
                    search.iOR(BugsSummaryTable.BugId, BaseFilter.ComparisonOperator.Contains, MiscUtils.GetSelectedValue(this.BugsSummarySearchArea1, this.GetFromSession(this.BugsSummarySearchArea1)), true, false);
        
                    search.iOR(BugsSummaryTable.Description, BaseFilter.ComparisonOperator.Contains, MiscUtils.GetSelectedValue(this.BugsSummarySearchArea1, this.GetFromSession(this.BugsSummarySearchArea1)), true, false);
        
                    search.iOR(BugsSummaryTable.StepsToReproduce, BaseFilter.ComparisonOperator.Contains, MiscUtils.GetSelectedValue(this.BugsSummarySearchArea1, this.GetFromSession(this.BugsSummarySearchArea1)), true, false);
        
                    search.iOR(BugsSummaryTable.Note, BaseFilter.ComparisonOperator.Contains, MiscUtils.GetSelectedValue(this.BugsSummarySearchArea1, this.GetFromSession(this.BugsSummarySearchArea1)), true, false);
        
                    search.iOR(BugsSummaryTable.TestCaseID, BaseFilter.ComparisonOperator.Contains, MiscUtils.GetSelectedValue(this.BugsSummarySearchArea1, this.GetFromSession(this.BugsSummarySearchArea1)), true, false);
        
                    search.iOR(BugsSummaryTable.TaskID, BaseFilter.ComparisonOperator.Contains, MiscUtils.GetSelectedValue(this.BugsSummarySearchArea1, this.GetFromSession(this.BugsSummarySearchArea1)), true, false);
        
                    wc.iAND(search);
                }
            }
                  
            if (MiscUtils.IsValueSelected(this.PriorityIDFilter1)) {
                wc.iAND(BugsSummaryTable.PriorityID, BaseFilter.ComparisonOperator.EqualsTo, MiscUtils.GetSelectedValue(this.PriorityIDFilter1, this.GetFromSession(this.PriorityIDFilter1)), false, false);
            }
                      
            return wc;
        }
            
        private void Control_PreRender(object sender, System.EventArgs e)
        {
            try {
                DbUtils.StartTransaction();
                
                if (!this.Page.ErrorOnPage && (this.Page.IsPageRefresh || this.DataChanged || this.ResetData)) {
                    this.LoadData();
                    this.DataBind();
                }
                
            } catch (Exception ex) {
                BaseClasses.Utils.MiscUtils.RegisterJScriptAlert(this, "BUTTON_CLICK_MESSAGE", ex.Message);
            } finally {
                DbUtils.EndTransaction();
            }
        }
        
        protected override void SaveControlsToSession()
        {
            base.SaveControlsToSession();

            // Save filter controls to values to session.
        
            this.SaveToSession(this.BugsSummarySearchArea1, this.BugsSummarySearchArea1.Text);
            this.SaveToSession(this.PriorityIDFilter1, this.PriorityIDFilter1.SelectedValue);
            this.SaveToSession(this.StatusIDFilter, this.StatusIDFilter.SelectedValue);
            
            // Save table control properties to the session.
            if (this.CurrentSortOrder != null) {
                this.SaveToSession(this, "Order_By", this.CurrentSortOrder.ToXmlString());
            }
            this.SaveToSession(this, "Page_Index", this.PageIndex.ToString());
            this.SaveToSession(this, "Page_Size", this.PageSize.ToString());
        
            this.SaveToSession(this, "DeletedRecordIds", this.DeletedRecordIds);
        
        }
        
        protected  void SaveControlsToSession_Ajax()
        {
            // Save filter controls to values to session.
          
            this.SaveToSession("BugsSummarySearchArea1_Ajax", this.BugsSummarySearchArea1.Text);
            this.SaveToSession("PriorityIDFilter1_Ajax", this.PriorityIDFilter1.SelectedValue);
            this.SaveToSession("StatusIDFilter_Ajax", this.StatusIDFilter.SelectedValue);
           HttpContext.Current.Session["AppRelatvieVirtualPath"] = this.Page.AppRelativeVirtualPath;
         
        }
        
        protected override void ClearControlsFromSession()
        {
            base.ClearControlsFromSession();

            // Clear filter controls values from the session.
        
            this.RemoveFromSession(this.BugsSummarySearchArea1);
            this.RemoveFromSession(this.PriorityIDFilter1);
            this.RemoveFromSession(this.StatusIDFilter);
            
            // Clear table properties from the session.
            this.RemoveFromSession(this, "Order_By");
            this.RemoveFromSession(this, "Page_Index");
            this.RemoveFromSession(this, "Page_Size");
            
            this.RemoveFromSession(this, "DeletedRecordIds");
            
        }

        protected override void LoadViewState(object savedState)
        {
            base.LoadViewState(savedState);

            string orderByStr = (string)ViewState["BugsSummaryTableControl1_OrderBy"];
            if (orderByStr != null && orderByStr.Length > 0) {
                this.CurrentSortOrder = BaseClasses.Data.OrderBy.FromXmlString(orderByStr);
            } else {
                this.CurrentSortOrder = new OrderBy(true, true);
            }

            if (ViewState["Page_Index"] != null) {
                this.PageIndex = (int)ViewState["Page_Index"];
            }

            if (ViewState["Page_Size"] != null) {
                this.PageSize = (int)ViewState["Page_Size"];
            }
        
            this.DeletedRecordIds = (string)this.ViewState["DeletedRecordIds"];
        
        }

        protected override object SaveViewState()
        {            
            if (this.CurrentSortOrder != null) {
                this.ViewState["BugsSummaryTableControl1_OrderBy"] = this.CurrentSortOrder.ToXmlString();
            }
            
            this.ViewState["Page_Index"] = this.PageIndex;
            this.ViewState["Page_Size"] = this.PageSize;
        
            this.ViewState["DeletedRecordIds"] = this.DeletedRecordIds;
        
            return (base.SaveViewState());
        }

        // Generate the event handling functions for pagination events.
        
              // event handler for ImageButton
              public virtual void BugsSummaryPagination1_FirstPage_Click(object sender, ImageClickEventArgs args)
              {
              
            try {
                
            this.PageIndex = 0;
            this.DataChanged = true;
      
            } catch (Exception ex) {
                this.Page.ErrorOnPage = true;
    
                BaseClasses.Utils.MiscUtils.RegisterJScriptAlert(this, "BUTTON_CLICK_MESSAGE", ex.Message);
            } finally {
    
            }
    
              }
            
              // event handler for ImageButton
              public virtual void BugsSummaryPagination1_LastPage_Click(object sender, ImageClickEventArgs args)
              {
              
            try {
                
            this.DisplayLastPage = true;
            this.DataChanged = true;
      
            } catch (Exception ex) {
                this.Page.ErrorOnPage = true;
    
                BaseClasses.Utils.MiscUtils.RegisterJScriptAlert(this, "BUTTON_CLICK_MESSAGE", ex.Message);
            } finally {
    
            }
    
              }
            
              // event handler for ImageButton
              public virtual void BugsSummaryPagination1_NextPage_Click(object sender, ImageClickEventArgs args)
              {
              
            try {
                
            this.PageIndex += 1;
            this.DataChanged = true;
      
            } catch (Exception ex) {
                this.Page.ErrorOnPage = true;
    
                BaseClasses.Utils.MiscUtils.RegisterJScriptAlert(this, "BUTTON_CLICK_MESSAGE", ex.Message);
            } finally {
    
            }
    
              }
            
              // event handler for LinkButton
              public virtual void BugsSummaryPagination1_PageSizeButton_Click(object sender, EventArgs args)
              {
              
            try {
                
            this.DataChanged = true;
            this.PageSize = Convert.ToInt32(this.BugsSummaryPagination1.PageSize.Text);
            this.PageIndex = Convert.ToInt32(this.BugsSummaryPagination1.CurrentPage.Text) - 1;
      
            } catch (Exception ex) {
                this.Page.ErrorOnPage = true;
    
                BaseClasses.Utils.MiscUtils.RegisterJScriptAlert(this, "BUTTON_CLICK_MESSAGE", ex.Message);
            } finally {
    
            }
    
              }
            
              // event handler for ImageButton
              public virtual void BugsSummaryPagination1_PreviousPage_Click(object sender, ImageClickEventArgs args)
              {
              
            try {
                
            if (this.PageIndex > 0) {
                this.PageIndex -= 1;
                this.DataChanged = true;
            }
      
            } catch (Exception ex) {
                this.Page.ErrorOnPage = true;
    
                BaseClasses.Utils.MiscUtils.RegisterJScriptAlert(this, "BUTTON_CLICK_MESSAGE", ex.Message);
            } finally {
    
            }
    
              }
            

        // Generate the event handling functions for sorting events.
        
              // event handler for FieldSort
              public virtual void AssignedLabel1_Click(object sender, EventArgs args)
              {
              
            OrderByItem sd = this.CurrentSortOrder.Find(BugsSummaryTable.Assigned);
            if (sd != null) {
                sd.Reverse();
            } else {
                this.CurrentSortOrder.Reset();
                this.CurrentSortOrder.Add(BugsSummaryTable.Assigned, OrderByItem.OrderDir.Asc);
            }

            this.DataChanged = true;
              
              }
            
              // event handler for FieldSort
              public virtual void BugIdLabel1_Click(object sender, EventArgs args)
              {
              
            OrderByItem sd = this.CurrentSortOrder.Find(BugsSummaryTable.BugId);
            if (sd != null) {
                sd.Reverse();
            } else {
                this.CurrentSortOrder.Reset();
                this.CurrentSortOrder.Add(BugsSummaryTable.BugId, OrderByItem.OrderDir.Asc);
            }

            this.DataChanged = true;
              
              }
            
              // event handler for FieldSort
              public virtual void BugShortDescriptionLabel1_Click(object sender, EventArgs args)
              {
              
            OrderByItem sd = this.CurrentSortOrder.Find(BugsSummaryTable.BugShortDescription);
            if (sd != null) {
                sd.Reverse();
            } else {
                this.CurrentSortOrder.Reset();
                this.CurrentSortOrder.Add(BugsSummaryTable.BugShortDescription, OrderByItem.OrderDir.Asc);
            }

            this.DataChanged = true;
              
              }
            
              // event handler for FieldSort
              public virtual void DateLabel1_Click(object sender, EventArgs args)
              {
              
            OrderByItem sd = this.CurrentSortOrder.Find(BugsSummaryTable.Date0);
            if (sd != null) {
                sd.Reverse();
            } else {
                this.CurrentSortOrder.Reset();
                this.CurrentSortOrder.Add(BugsSummaryTable.Date0, OrderByItem.OrderDir.Asc);
            }

            this.DataChanged = true;
              
              }
            
              // event handler for FieldSort
              public virtual void DescriptionLabel1_Click(object sender, EventArgs args)
              {
              
            OrderByItem sd = this.CurrentSortOrder.Find(BugsSummaryTable.Description);
            if (sd != null) {
                sd.Reverse();
            } else {
                this.CurrentSortOrder.Reset();
                this.CurrentSortOrder.Add(BugsSummaryTable.Description, OrderByItem.OrderDir.Asc);
            }

            this.DataChanged = true;
              
              }
            
              // event handler for FieldSort
              public virtual void EnvBUGLOGmentLabel1_Click(object sender, EventArgs args)
              {
              
            OrderByItem sd = this.CurrentSortOrder.Find(BugsSummaryTable.EnvBUGLOGment);
            if (sd != null) {
                sd.Reverse();
            } else {
                this.CurrentSortOrder.Reset();
                this.CurrentSortOrder.Add(BugsSummaryTable.EnvBUGLOGment, OrderByItem.OrderDir.Asc);
            }

            this.DataChanged = true;
              
              }
            
              // event handler for FieldSort
              public virtual void FixedByLabel1_Click(object sender, EventArgs args)
              {
              
            OrderByItem sd = this.CurrentSortOrder.Find(BugsSummaryTable.FixedBy);
            if (sd != null) {
                sd.Reverse();
            } else {
                this.CurrentSortOrder.Reset();
                this.CurrentSortOrder.Add(BugsSummaryTable.FixedBy, OrderByItem.OrderDir.Asc);
            }

            this.DataChanged = true;
              
              }
            
              // event handler for FieldSort
              public virtual void PriorityIDLabel3_Click(object sender, EventArgs args)
              {
              
            OrderByItem sd = this.CurrentSortOrder.Find(BugsSummaryTable.PriorityID);
            if (sd != null) {
                sd.Reverse();
            } else {
                this.CurrentSortOrder.Reset();
                this.CurrentSortOrder.Add(BugsSummaryTable.PriorityID, OrderByItem.OrderDir.Asc);
            }

            this.DataChanged = true;
              
              }
            
              // event handler for FieldSort
              public virtual void StatusIDLabel1_Click(object sender, EventArgs args)
              {
              
            OrderByItem sd = this.CurrentSortOrder.Find(BugsSummaryTable.StatusID);
            if (sd != null) {
                sd.Reverse();
            } else {
                this.CurrentSortOrder.Reset();
                this.CurrentSortOrder.Add(BugsSummaryTable.StatusID, OrderByItem.OrderDir.Asc);
            }

            this.DataChanged = true;
              
              }
            
              // event handler for FieldSort
              public virtual void StepsToReproduceLabel1_Click(object sender, EventArgs args)
              {
              
            OrderByItem sd = this.CurrentSortOrder.Find(BugsSummaryTable.StepsToReproduce);
            if (sd != null) {
                sd.Reverse();
            } else {
                this.CurrentSortOrder.Reset();
                this.CurrentSortOrder.Add(BugsSummaryTable.StepsToReproduce, OrderByItem.OrderDir.Asc);
            }

            this.DataChanged = true;
              
              }
            
              // event handler for FieldSort
              public virtual void TaskIDLabel2_Click(object sender, EventArgs args)
              {
              
            OrderByItem sd = this.CurrentSortOrder.Find(BugsSummaryTable.TaskID);
            if (sd != null) {
                sd.Reverse();
            } else {
                this.CurrentSortOrder.Reset();
                this.CurrentSortOrder.Add(BugsSummaryTable.TaskID, OrderByItem.OrderDir.Asc);
            }

            this.DataChanged = true;
              
              }
            
              // event handler for FieldSort
              public virtual void TestCaseIDLabel1_Click(object sender, EventArgs args)
              {
              
            OrderByItem sd = this.CurrentSortOrder.Find(BugsSummaryTable.TestCaseID);
            if (sd != null) {
                sd.Reverse();
            } else {
                this.CurrentSortOrder.Reset();
                this.CurrentSortOrder.Add(BugsSummaryTable.TestCaseID, OrderByItem.OrderDir.Asc);
            }

            this.DataChanged = true;
              
              }
            
              // event handler for FieldSort
              public virtual void userIDLabel3_Click(object sender, EventArgs args)
              {
              
            OrderByItem sd = this.CurrentSortOrder.Find(BugsSummaryTable.UserId0);
            if (sd != null) {
                sd.Reverse();
            } else {
                this.CurrentSortOrder.Reset();
                this.CurrentSortOrder.Add(BugsSummaryTable.UserId0, OrderByItem.OrderDir.Asc);
            }

            this.DataChanged = true;
              
              }
            

        // Generate the event handling functions for button events.
        
              // event handler for ImageButton
              public virtual void BugsSummaryCopyButton1_Click(object sender, ImageClickEventArgs args)
              {
              
            string url = @"../BugsSummary/AddBugsSummaryPage.aspx?BugsSummary={PK}";
            bool shouldRedirect = true;
            string TargetKey = null;
            string DFKA = null;
            string id = null;
            string value = null;
            try {
                DbUtils.StartTransaction();
                
                url = this.ModifyRedirectUrl(url, "",false);
                url = this.Page.ModifyRedirectUrl(url, "",false);
                        this.Page.CommitTransaction(sender);
      
            } catch (Exception ex) {
                this.Page.RollBackTransaction(sender);
                shouldRedirect = false;
                this.Page.ErrorOnPage = true;
    
                throw ex;
            } finally {
                DbUtils.EndTransaction();
            }
            if (shouldRedirect) {
                this.Page.ShouldSaveControlsToSession = true;
                this.Page.Response.Redirect(url);
            }
        
            else if (TargetKey != null && !shouldRedirect){
            this.Page.ShouldSaveControlsToSession = true ; 
            this.Page.CloseWindow(true);
            }
        
              }
            
              // event handler for ImageButton
              public virtual void BugsSummaryDeleteButton1_Click(object sender, ImageClickEventArgs args)
              {
              
            try {
                DbUtils.StartTransaction();
                
            if (!this.Page.IsPageRefresh) {
        
                this.DeleteSelectedRecords(false);
          
            }
                this.Page.CommitTransaction(sender);
      
            } catch (Exception ex) {
                this.Page.RollBackTransaction(sender);
                this.Page.ErrorOnPage = true;
    
                throw ex;
            } finally {
                DbUtils.EndTransaction();
            }
    
              }
            
              // event handler for ImageButton
              public virtual void BugsSummaryEditButton1_Click(object sender, ImageClickEventArgs args)
              {
              
            string url = @"../BugsSummary/EditBugsSummaryPage.aspx?BugsSummary={PK}";
            bool shouldRedirect = true;
            string TargetKey = null;
            string DFKA = null;
            string id = null;
            string value = null;
            try {
                DbUtils.StartTransaction();
                
                url = this.ModifyRedirectUrl(url, "",false);
                url = this.Page.ModifyRedirectUrl(url, "",false);
                        this.Page.CommitTransaction(sender);
      
            } catch (Exception ex) {
                this.Page.RollBackTransaction(sender);
                shouldRedirect = false;
                this.Page.ErrorOnPage = true;
    
                throw ex;
            } finally {
                DbUtils.EndTransaction();
            }
            if (shouldRedirect) {
                this.Page.ShouldSaveControlsToSession = true;
                this.Page.Response.Redirect(url);
            }
        
            else if (TargetKey != null && !shouldRedirect){
            this.Page.ShouldSaveControlsToSession = true ; 
            this.Page.CloseWindow(true);
            }
        
              }
            
              // event handler for ImageButton
              public virtual void BugsSummaryExportButton1_Click(object sender, ImageClickEventArgs args)
              {
              
            try {
                DbUtils.StartTransaction();
                
              WhereClause wc = CreateWhereClause();
              OrderBy orderBy = CreateOrderBy();
            
          BaseColumn[] columns = new BaseColumn[] {
                       BugsSummaryTable.BugId,
             BugsSummaryTable.BugShortDescription,
             BugsSummaryTable.Date0,
             BugsSummaryTable.UserId0,
             BugsSummaryTable.PriorityID,
             BugsSummaryTable.StatusID,
             BugsSummaryTable.Assigned,
             BugsSummaryTable.FixedBy,
             BugsSummaryTable.Description,
             BugsSummaryTable.EnvBUGLOGment,
             BugsSummaryTable.StepsToReproduce,
             BugsSummaryTable.Note,
             BugsSummaryTable.TaskID,
             BugsSummaryTable.TestCaseID,
             null};
            ExportData rep = new ExportData(BugsSummaryTable.Instance,wc,orderBy,columns);
            rep.ExportToCSV(this.Page.Response);
                  this.Page.CommitTransaction(sender);
      
            } catch (Exception ex) {
                this.Page.RollBackTransaction(sender);
                this.Page.ErrorOnPage = true;
    
                BaseClasses.Utils.MiscUtils.RegisterJScriptAlert(this, "BUTTON_CLICK_MESSAGE", ex.Message);
            } finally {
                DbUtils.EndTransaction();
            }
    
              }
            
              // event handler for ImageButton
              public virtual void BugsSummaryExportExcelButton1_Click(object sender, ImageClickEventArgs args)
              {
              
            try {
                DbUtils.StartTransaction();
                
            // To customize the columns or the format, override this function in Section 1 of the page
            // and modify it to your liking.
            // Build the where clause based on the current filter and search criteria
            // Create the Order By clause based on the user's current sorting preference.
            
                WhereClause wc = CreateWhereClause();
                OrderBy orderBy = CreateOrderBy();
              
            // Create an instance of the Excel report class with the table class, where clause and order by.
            ExportData excelReport = new ExportData(BugsSummaryTable.Instance, wc, orderBy);
            // Add each of the columns in order of export.
            // To customize the data type, change the second parameter of the new ExcelColumn to be
            // a format string from Excel's Format Cell menu. For example "dddd, mmmm dd, yyyy h:mm AM/PM;@", "#,##0.00"
             excelReport.AddColumn(new ExcelColumn(BugsSummaryTable.BugId, "Standard"));
             excelReport.AddColumn(new ExcelColumn(BugsSummaryTable.BugShortDescription, "Default"));
             excelReport.AddColumn(new ExcelColumn(BugsSummaryTable.Date0, "Short Date"));
             excelReport.AddColumn(new ExcelColumn(BugsSummaryTable.UserId0, "Default"));
             excelReport.AddColumn(new ExcelColumn(BugsSummaryTable.PriorityID, "Default"));
             excelReport.AddColumn(new ExcelColumn(BugsSummaryTable.StatusID, "Default"));
             excelReport.AddColumn(new ExcelColumn(BugsSummaryTable.Assigned, "Default"));
             excelReport.AddColumn(new ExcelColumn(BugsSummaryTable.FixedBy, "Default"));
             excelReport.AddColumn(new ExcelColumn(BugsSummaryTable.Description, "Default"));
             excelReport.AddColumn(new ExcelColumn(BugsSummaryTable.EnvBUGLOGment, "Default"));
             excelReport.AddColumn(new ExcelColumn(BugsSummaryTable.StepsToReproduce, "Default"));
             excelReport.AddColumn(new ExcelColumn(BugsSummaryTable.Note, "Default"));
             excelReport.AddColumn(new ExcelColumn(BugsSummaryTable.TaskID, "Default"));
             excelReport.AddColumn(new ExcelColumn(BugsSummaryTable.TestCaseID, "Default"));

            excelReport.ExportToExcel(this.Page.Response);
                    this.Page.CommitTransaction(sender);
      
            } catch (Exception ex) {
                this.Page.RollBackTransaction(sender);
                this.Page.ErrorOnPage = true;
    
                BaseClasses.Utils.MiscUtils.RegisterJScriptAlert(this, "BUTTON_CLICK_MESSAGE", ex.Message);
            } finally {
                DbUtils.EndTransaction();
            }
    
              }
            
              // event handler for ImageButton
              public virtual void BugsSummaryNewButton1_Click(object sender, ImageClickEventArgs args)
              {
              
            string url = @"../BugsSummary/AddBugsSummaryPage.aspx";
            bool shouldRedirect = true;
            string TargetKey = null;
            string DFKA = null;
            string id = null;
            string value = null;
            try {
                DbUtils.StartTransaction();
                
                url = this.ModifyRedirectUrl(url, "",false);
                url = this.Page.ModifyRedirectUrl(url, "",false);
                        this.Page.CommitTransaction(sender);
      
            } catch (Exception ex) {
                this.Page.RollBackTransaction(sender);
                shouldRedirect = false;
                this.Page.ErrorOnPage = true;
    
                throw ex;
            } finally {
                DbUtils.EndTransaction();
            }
            if (shouldRedirect) {
                this.Page.ShouldSaveControlsToSession = true;
                this.Page.Response.Redirect(url);
            }
        
            else if (TargetKey != null && !shouldRedirect){
            this.Page.ShouldSaveControlsToSession = true ; 
            this.Page.CloseWindow(true);
            }
        
              }
            
              // event handler for ImageButton
              public virtual void BugsSummaryPDFButton1_Click(object sender, ImageClickEventArgs args)
              {
              
            try {
                DbUtils.StartTransaction();
                

        PDFReport report = new PDFReport();

        report.SpecificReportFileName = Page.Server.MapPath("ShowBugsSummaryTablePage.BugsSummaryPDFButton1.report");
                // report.Title replaces the value tag of page header and footer containing ${ReportTitle}
                report.Title = "BugsSummary";
                // If ShowBugsSummaryTablePage.BugsSummaryPDFButton1.report specifies a valid report template,
                // AddColumn methods will generate a report template.   
                // Each AddColumn method-call specifies a column
                // The 1st parameter represents the text of the column header
                // The 2nd parameter represents the horizontal alignment of the column header
                // The 3rd parameter represents the text format of the column detail
                // The 4th parameter represents the horizontal alignment of the column detail
                // The 5th parameter represents the relative width of the column
                 report.AddColumn(BugsSummaryTable.BugId.Name, ReportEnum.Align.Right, "${BugsSummaryTable.BugId.Name}", ReportEnum.Align.Right, 15);
                 report.AddColumn(BugsSummaryTable.BugShortDescription.Name, ReportEnum.Align.Left, "${BugsSummaryTable.BugShortDescription.Name}", ReportEnum.Align.Left, 30);
                 report.AddColumn(BugsSummaryTable.Date0.Name, ReportEnum.Align.Left, "${BugsSummaryTable.Date0.Name}", ReportEnum.Align.Left, 20);
                 report.AddColumn(BugsSummaryTable.UserId0.Name, ReportEnum.Align.Left, "${BugsSummaryTable.UserId0.Name}", ReportEnum.Align.Left, 20);
                 report.AddColumn(BugsSummaryTable.PriorityID.Name, ReportEnum.Align.Left, "${BugsSummaryTable.PriorityID.Name}", ReportEnum.Align.Left, 20);
                 report.AddColumn(BugsSummaryTable.StatusID.Name, ReportEnum.Align.Left, "${BugsSummaryTable.StatusID.Name}", ReportEnum.Align.Left, 20);
                 report.AddColumn(BugsSummaryTable.Assigned.Name, ReportEnum.Align.Left, "${BugsSummaryTable.Assigned.Name}", ReportEnum.Align.Left, 20);
                 report.AddColumn(BugsSummaryTable.FixedBy.Name, ReportEnum.Align.Left, "${BugsSummaryTable.FixedBy.Name}", ReportEnum.Align.Left, 20);
                 report.AddColumn(BugsSummaryTable.Description.Name, ReportEnum.Align.Left, "${BugsSummaryTable.Description.Name}", ReportEnum.Align.Left, 30);
                 report.AddColumn(BugsSummaryTable.EnvBUGLOGment.Name, ReportEnum.Align.Left, "${BugsSummaryTable.EnvBUGLOGment.Name}", ReportEnum.Align.Left, 30);
                 report.AddColumn(BugsSummaryTable.StepsToReproduce.Name, ReportEnum.Align.Left, "${BugsSummaryTable.StepsToReproduce.Name}", ReportEnum.Align.Left, 30);
                 report.AddColumn(BugsSummaryTable.Note.Name, ReportEnum.Align.Left, "${BugsSummaryTable.Note.Name}", ReportEnum.Align.Left, 30);
                 report.AddColumn(BugsSummaryTable.TaskID.Name, ReportEnum.Align.Left, "${BugsSummaryTable.TaskID.Name}", ReportEnum.Align.Left, 30);
                 report.AddColumn(BugsSummaryTable.TestCaseID.Name, ReportEnum.Align.Left, "${BugsSummaryTable.TestCaseID.Name}", ReportEnum.Align.Left, 20);

            WhereClause whereClause = CreateWhereClause();
            OrderBy orderBy = CreateOrderBy();
          

                int rowsPerQuery = 1000;
                int pageNum = 0;
                int recordCount = 0;
                int totalRecords = BugsSummaryTable.GetRecordCount(whereClause);
                                
                report.Page = Page.GetResourceValue("Txt:Page", "BUGLOG");
                report.ApplicationPath = this.Page.MapPath(Page.Request.ApplicationPath);

                ColumnList columns = BugsSummaryTable.GetColumnList();
                BugsSummaryRecord[] records = null;
                do
                {
                    records = BugsSummaryTable.GetRecords(whereClause, orderBy, pageNum, rowsPerQuery);
                    if (records != null && records.Length > 0)
                    {
                        foreach ( BugsSummaryRecord record in records)
                        {
                            // AddData method takes four parameters   
                            // The 1st parameters represents the data format
                            // The 2nd parameters represents the data value
                            // The 3rd parameters represents the default alignment of column using the data
                            // The 4th parameters represents the maximum length of the data value being shown
                             report.AddData("${BugsSummaryTable.BugId.Name}", record.Format(BugsSummaryTable.BugId), ReportEnum.Align.Right, 100);
                             report.AddData("${BugsSummaryTable.BugShortDescription.Name}", record.Format(BugsSummaryTable.BugShortDescription), ReportEnum.Align.Left, 100);
                             report.AddData("${BugsSummaryTable.Date0.Name}", record.Format(BugsSummaryTable.Date0), ReportEnum.Align.Left, 100);
                             report.AddData("${BugsSummaryTable.UserId0.Name}", record.Format(BugsSummaryTable.UserId0), ReportEnum.Align.Left);
                             report.AddData("${BugsSummaryTable.PriorityID.Name}", record.Format(BugsSummaryTable.PriorityID), ReportEnum.Align.Left);
                             report.AddData("${BugsSummaryTable.StatusID.Name}", record.Format(BugsSummaryTable.StatusID), ReportEnum.Align.Left);
                             report.AddData("${BugsSummaryTable.Assigned.Name}", record.Format(BugsSummaryTable.Assigned), ReportEnum.Align.Left);
                             report.AddData("${BugsSummaryTable.FixedBy.Name}", record.Format(BugsSummaryTable.FixedBy), ReportEnum.Align.Left);
                             report.AddData("${BugsSummaryTable.Description.Name}", record.Format(BugsSummaryTable.Description), ReportEnum.Align.Left, 100);
                             report.AddData("${BugsSummaryTable.EnvBUGLOGment.Name}", record.Format(BugsSummaryTable.EnvBUGLOGment), ReportEnum.Align.Left, 100);
                             report.AddData("${BugsSummaryTable.StepsToReproduce.Name}", record.Format(BugsSummaryTable.StepsToReproduce), ReportEnum.Align.Left, 100);
                             report.AddData("${BugsSummaryTable.Note.Name}", record.Format(BugsSummaryTable.Note), ReportEnum.Align.Left, 100);
                             report.AddData("${BugsSummaryTable.TaskID.Name}", record.Format(BugsSummaryTable.TaskID), ReportEnum.Align.Left);
                             report.AddData("${BugsSummaryTable.TestCaseID.Name}", record.Format(BugsSummaryTable.TestCaseID), ReportEnum.Align.Left);

                            report.WriteRow();
                        }
                        pageNum++;
                        recordCount += records.Length;
                    }
                }
                while (records != null && recordCount < totalRecords);
                report.Close();
                BaseClasses.Utils.NetUtils.WriteResponseBinaryAttachment(this.Page.Response, report.Title + ".pdf", report.ReportInByteArray, 0, true);
                      this.Page.CommitTransaction(sender);
      
            } catch (Exception ex) {
                this.Page.RollBackTransaction(sender);
                this.Page.ErrorOnPage = true;
    
                BaseClasses.Utils.MiscUtils.RegisterJScriptAlert(this, "BUTTON_CLICK_MESSAGE", ex.Message);
            } finally {
                DbUtils.EndTransaction();
            }
    
              }
            
              // event handler for ImageButton
              public virtual void BugsSummaryRefreshButton1_Click(object sender, ImageClickEventArgs args)
              {
              
            try {
                
            ((BugsSummaryTableControl1)(this.Page.FindControlRecursively("BugsSummaryTableControl1"))).ResetData = true;
                
            } catch (Exception ex) {
                this.Page.ErrorOnPage = true;
    
                throw ex;
            } finally {
    
            }
    
              }
            
              // event handler for ImageButton
              public virtual void BugsSummaryResetButton1_Click(object sender, ImageClickEventArgs args)
              {
              
            try {
                
              this.PriorityIDFilter1.ClearSelection();
            
              this.StatusIDFilter.ClearSelection();
            
              this.BugsSummarySearchArea1.Text = "";
            
              this.CurrentSortOrder.Reset();
              if (this.InSession(this, "Order_By")) {
              this.CurrentSortOrder = OrderBy.FromXmlString(this.GetFromSession(this, "Order_By", null));
              } else {
              this.CurrentSortOrder = new OrderBy(true, true);
            
              this.CurrentSortOrder.Add(BugsSummaryTable.BugId, OrderByItem.OrderDir.Asc);
            
              this.CurrentSortOrder.Add(BugsSummaryTable.Date0, OrderByItem.OrderDir.Asc);
            
            }

            this.DataChanged = true;
                
            } catch (Exception ex) {
                this.Page.ErrorOnPage = true;
    
                throw ex;
            } finally {
    
            }
    
              }
            
              // event handler for Button with Layout
              public virtual void BugsSummarySearchButton1_Click(object sender, EventArgs args)
              {
              
            try {
                
            this.DataChanged = true;
      
            } catch (Exception ex) {
                this.Page.ErrorOnPage = true;
    
                throw ex;
            } finally {
    
            }
    
              }
            

        // Generate the event handling functions for filter and search events.
        
        // event handler for FieldFilter
        protected virtual void PriorityIDFilter1_SelectedIndexChanged(object sender, EventArgs args)
        {
            this.DataChanged = true;
        }
            
        // event handler for FieldFilter
        protected virtual void StatusIDFilter_SelectedIndexChanged(object sender, EventArgs args)
        {
            this.DataChanged = true;
        }
            

        // verify the processing details for these properties
        private int _PageSize;
        public int PageSize {
            get {
                return this._PageSize;
            }
            set {
                this._PageSize = value;
            }
        }

        private int _PageIndex;
        public int PageIndex {
            get {
                // _PageSize return (the PageIndex);
                return this._PageIndex;
            }
            set {
                this._PageIndex = value;
            }
        }

        private int _TotalRecords;
        public int TotalRecords {
            get {
                return (this._TotalRecords);
            }
            set {
                if (this.PageSize > 0) {
                    this.TotalPages = Convert.ToInt32(Math.Ceiling(Convert.ToDouble(value) / Convert.ToDouble(this.PageSize)));
                }
                this._TotalRecords = value;
            }
        }

        private int _TotalPages;
        public int TotalPages {
            get {
                return this._TotalPages;
            }
            set {
                this._TotalPages = value;
            }
        }

        private bool _DisplayLastPage;
        public bool DisplayLastPage {
            get {
                return this._DisplayLastPage;
            }
            set {
                this._DisplayLastPage = value;
            }
        }

        private bool _DataChanged = false;
        public bool DataChanged {
            get {
                return this._DataChanged;
            }
            set {
                this._DataChanged = value;
            }
        }

        private bool _ResetData = false;
        public bool ResetData {
            get {
                return this._ResetData;
            }
            set {
                this._ResetData = value;
            }
        }

        private int _AddNewRecord = 0;
        public int AddNewRecord {
            get {
                return this._AddNewRecord;
            }
            set {
                this._AddNewRecord = value;
            }
        }

        private OrderBy _CurrentSortOrder = null;
        public OrderBy CurrentSortOrder {
            get {
                return this._CurrentSortOrder;
            }
            set {
                this._CurrentSortOrder = value;
            }
        }

        private BugsSummaryRecord[] _DataSource = null;
        public  BugsSummaryRecord[] DataSource {
            get {
                return this._DataSource;
            }
            set {
                this._DataSource = value;
            }
        }

#region "Helper Properties"
        
        public System.Web.UI.WebControls.LinkButton AssignedLabel1 {
            get {
                return (System.Web.UI.WebControls.LinkButton)BaseClasses.Utils.MiscUtils.FindControlRecursively(this, "AssignedLabel1");
            }
        }
        
        public System.Web.UI.WebControls.LinkButton BugIdLabel1 {
            get {
                return (System.Web.UI.WebControls.LinkButton)BaseClasses.Utils.MiscUtils.FindControlRecursively(this, "BugIdLabel1");
            }
        }
        
        public System.Web.UI.WebControls.LinkButton BugShortDescriptionLabel1 {
            get {
                return (System.Web.UI.WebControls.LinkButton)BaseClasses.Utils.MiscUtils.FindControlRecursively(this, "BugShortDescriptionLabel1");
            }
        }
        
        public System.Web.UI.WebControls.ImageButton BugsSummaryCopyButton1 {
            get {
                return (System.Web.UI.WebControls.ImageButton)BaseClasses.Utils.MiscUtils.FindControlRecursively(this, "BugsSummaryCopyButton1");
            }
        }
        
        public System.Web.UI.WebControls.ImageButton BugsSummaryDeleteButton1 {
            get {
                return (System.Web.UI.WebControls.ImageButton)BaseClasses.Utils.MiscUtils.FindControlRecursively(this, "BugsSummaryDeleteButton1");
            }
        }
        
        public System.Web.UI.WebControls.ImageButton BugsSummaryEditButton1 {
            get {
                return (System.Web.UI.WebControls.ImageButton)BaseClasses.Utils.MiscUtils.FindControlRecursively(this, "BugsSummaryEditButton1");
            }
        }
        
        public System.Web.UI.WebControls.ImageButton BugsSummaryExportButton1 {
            get {
                return (System.Web.UI.WebControls.ImageButton)BaseClasses.Utils.MiscUtils.FindControlRecursively(this, "BugsSummaryExportButton1");
            }
        }
        
        public System.Web.UI.WebControls.ImageButton BugsSummaryExportExcelButton1 {
            get {
                return (System.Web.UI.WebControls.ImageButton)BaseClasses.Utils.MiscUtils.FindControlRecursively(this, "BugsSummaryExportExcelButton1");
            }
        }
        
        public System.Web.UI.WebControls.ImageButton BugsSummaryNewButton1 {
            get {
                return (System.Web.UI.WebControls.ImageButton)BaseClasses.Utils.MiscUtils.FindControlRecursively(this, "BugsSummaryNewButton1");
            }
        }
        
        public BUGLOG.UI.IPagination BugsSummaryPagination1 {
            get {
                return (BUGLOG.UI.IPagination)BaseClasses.Utils.MiscUtils.FindControlRecursively(this, "BugsSummaryPagination1");
            }
        }
        
        public System.Web.UI.WebControls.ImageButton BugsSummaryPDFButton1 {
            get {
                return (System.Web.UI.WebControls.ImageButton)BaseClasses.Utils.MiscUtils.FindControlRecursively(this, "BugsSummaryPDFButton1");
            }
        }
        
        public System.Web.UI.WebControls.ImageButton BugsSummaryRefreshButton1 {
            get {
                return (System.Web.UI.WebControls.ImageButton)BaseClasses.Utils.MiscUtils.FindControlRecursively(this, "BugsSummaryRefreshButton1");
            }
        }
        
        public System.Web.UI.WebControls.ImageButton BugsSummaryResetButton1 {
            get {
                return (System.Web.UI.WebControls.ImageButton)BaseClasses.Utils.MiscUtils.FindControlRecursively(this, "BugsSummaryResetButton1");
            }
        }
        
        public System.Web.UI.WebControls.TextBox BugsSummarySearchArea1 {
            get {
                return (System.Web.UI.WebControls.TextBox)BaseClasses.Utils.MiscUtils.FindControlRecursively(this, "BugsSummarySearchArea1");
            }
        }
        
        public BUGLOG.UI.IThemeButton BugsSummarySearchButton1 {
            get {
                return (BUGLOG.UI.IThemeButton)BaseClasses.Utils.MiscUtils.FindControlRecursively(this, "BugsSummarySearchButton1");
            }
        }
        
        public System.Web.UI.WebControls.Literal BugsSummaryTableTitle1 {
            get {
                return (System.Web.UI.WebControls.Literal)BaseClasses.Utils.MiscUtils.FindControlRecursively(this, "BugsSummaryTableTitle1");
            }
        }
        
        public System.Web.UI.WebControls.CheckBox BugsSummaryToggleAll1 {
            get {
                return (System.Web.UI.WebControls.CheckBox)BaseClasses.Utils.MiscUtils.FindControlRecursively(this, "BugsSummaryToggleAll1");
            }
        }
        
        public System.Web.UI.WebControls.Label BugsSummaryTotalItems1 {
            get {
                return (System.Web.UI.WebControls.Label)BaseClasses.Utils.MiscUtils.FindControlRecursively(this, "BugsSummaryTotalItems1");
            }
        }
        
        public System.Web.UI.WebControls.LinkButton DateLabel1 {
            get {
                return (System.Web.UI.WebControls.LinkButton)BaseClasses.Utils.MiscUtils.FindControlRecursively(this, "DateLabel1");
            }
        }
        
        public System.Web.UI.WebControls.LinkButton DescriptionLabel1 {
            get {
                return (System.Web.UI.WebControls.LinkButton)BaseClasses.Utils.MiscUtils.FindControlRecursively(this, "DescriptionLabel1");
            }
        }
        
        public System.Web.UI.WebControls.LinkButton EnvBUGLOGmentLabel1 {
            get {
                return (System.Web.UI.WebControls.LinkButton)BaseClasses.Utils.MiscUtils.FindControlRecursively(this, "EnvBUGLOGmentLabel1");
            }
        }
        
        public System.Web.UI.WebControls.LinkButton FixedByLabel1 {
            get {
                return (System.Web.UI.WebControls.LinkButton)BaseClasses.Utils.MiscUtils.FindControlRecursively(this, "FixedByLabel1");
            }
        }
        
        public System.Web.UI.WebControls.Literal ImageAttachmentLabel1 {
            get {
                return (System.Web.UI.WebControls.Literal)BaseClasses.Utils.MiscUtils.FindControlRecursively(this, "ImageAttachmentLabel1");
            }
        }
        
        public System.Web.UI.WebControls.Literal NoteLabel1 {
            get {
                return (System.Web.UI.WebControls.Literal)BaseClasses.Utils.MiscUtils.FindControlRecursively(this, "NoteLabel1");
            }
        }
        
        public System.Web.UI.WebControls.DropDownList PriorityIDFilter1 {
            get {
                return (System.Web.UI.WebControls.DropDownList)BaseClasses.Utils.MiscUtils.FindControlRecursively(this, "PriorityIDFilter1");
            }
        }
        
        public System.Web.UI.WebControls.Literal PriorityIDLabel2 {
            get {
                return (System.Web.UI.WebControls.Literal)BaseClasses.Utils.MiscUtils.FindControlRecursively(this, "PriorityIDLabel2");
            }
        }
        
        public System.Web.UI.WebControls.LinkButton PriorityIDLabel3 {
            get {
                return (System.Web.UI.WebControls.LinkButton)BaseClasses.Utils.MiscUtils.FindControlRecursively(this, "PriorityIDLabel3");
            }
        }
        
        public System.Web.UI.WebControls.DropDownList StatusIDFilter {
            get {
                return (System.Web.UI.WebControls.DropDownList)BaseClasses.Utils.MiscUtils.FindControlRecursively(this, "StatusIDFilter");
            }
        }
        
        public System.Web.UI.WebControls.Literal StatusIDLabel {
            get {
                return (System.Web.UI.WebControls.Literal)BaseClasses.Utils.MiscUtils.FindControlRecursively(this, "StatusIDLabel");
            }
        }
        
        public System.Web.UI.WebControls.LinkButton StatusIDLabel1 {
            get {
                return (System.Web.UI.WebControls.LinkButton)BaseClasses.Utils.MiscUtils.FindControlRecursively(this, "StatusIDLabel1");
            }
        }
        
        public System.Web.UI.WebControls.LinkButton StepsToReproduceLabel1 {
            get {
                return (System.Web.UI.WebControls.LinkButton)BaseClasses.Utils.MiscUtils.FindControlRecursively(this, "StepsToReproduceLabel1");
            }
        }
        
        public System.Web.UI.WebControls.LinkButton TaskIDLabel2 {
            get {
                return (System.Web.UI.WebControls.LinkButton)BaseClasses.Utils.MiscUtils.FindControlRecursively(this, "TaskIDLabel2");
            }
        }
        
        public System.Web.UI.WebControls.LinkButton TestCaseIDLabel1 {
            get {
                return (System.Web.UI.WebControls.LinkButton)BaseClasses.Utils.MiscUtils.FindControlRecursively(this, "TestCaseIDLabel1");
            }
        }
        
        public System.Web.UI.WebControls.LinkButton userIDLabel3 {
            get {
                return (System.Web.UI.WebControls.LinkButton)BaseClasses.Utils.MiscUtils.FindControlRecursively(this, "userIDLabel3");
            }
        }
        
#endregion

#region "Helper Functions"
        
                public override string ModifyRedirectUrl(string url, string arg, bool bEncrypt)
              
        {
            bool needToProcess = AreAnyUrlParametersForMe(url, arg);
            if (needToProcess) {
                BugsSummaryTableControl1Row recCtl = this.GetSelectedRecordControl();
                if (recCtl == null && url.IndexOf("{") >= 0) {
                    // Localization.
                    throw new Exception(Page.GetResourceValue("Err:NoRecSelected", "BUGLOG"));
                }

                BugsSummaryRecord rec = null;
                if (recCtl != null) {
                    rec = recCtl.GetRecord();
                }
            
                return ModifyRedirectUrl(url, arg, rec, bEncrypt);
              
            }
            return url;
        }
          
        public int GetSelectedRecordIndex()
        {
            int counter = 0;
            foreach (BugsSummaryTableControl1Row recControl in this.GetRecordControls())
            {
                if (recControl.BugsSummaryRecordRowSelection1.Checked) {
                    return counter;
                }
                counter += 1;
            }
            return -1;
        }
        
        public BugsSummaryTableControl1Row GetSelectedRecordControl()
        {
        BugsSummaryTableControl1Row[] selectedList = this.GetSelectedRecordControls();
            if (selectedList.Length == 0) {
            return null;
            }
            return selectedList[0];
          
        }

        public BugsSummaryTableControl1Row[] GetSelectedRecordControls()
        {
        
            ArrayList selectedList = new ArrayList(25);
            foreach (BugsSummaryTableControl1Row recControl in this.GetRecordControls())
            {
                if (recControl.BugsSummaryRecordRowSelection1.Checked) {
                    selectedList.Add(recControl);
                }
            }
            return (BugsSummaryTableControl1Row[])(selectedList.ToArray(Type.GetType("BUGLOG.UI.Controls.ShowBugsSummaryTablePage.BugsSummaryTableControl1Row")));
          
        }

        public virtual void DeleteSelectedRecords(bool deferDeletion)
        {
            BugsSummaryTableControl1Row[] recList = this.GetSelectedRecordControls();
            if (recList.Length == 0) {
                // Localization.
                throw new Exception(Page.GetResourceValue("Err:NoRecSelected", "BUGLOG"));
            }
            
            foreach (BugsSummaryTableControl1Row recCtl in recList)
            {
                if (deferDeletion) {
                    if (!recCtl.IsNewRecord) {
                
                        this.AddToDeletedRecordIds(recCtl);
                  
                    }
                    recCtl.Visible = false;
                
                    recCtl.BugsSummaryRecordRowSelection1.Checked = false;
                
                } else {
                
                    recCtl.Delete();
                    this.DataChanged = true;
                    this.ResetData = true;
                  
                }
            }
        }

        public BugsSummaryTableControl1Row[] GetRecordControls()
        {
            ArrayList recList = new ArrayList();
            System.Web.UI.WebControls.Repeater rep = (System.Web.UI.WebControls.Repeater)this.FindControl("BugsSummaryTableControl1Repeater");

            foreach (System.Web.UI.WebControls.RepeaterItem repItem in rep.Items)
            {
                BugsSummaryTableControl1Row recControl = (BugsSummaryTableControl1Row)repItem.FindControl("BugsSummaryTableControl1Row");
                recList.Add(recControl);
            }

            return (BugsSummaryTableControl1Row[])recList.ToArray(Type.GetType("BUGLOG.UI.Controls.ShowBugsSummaryTablePage.BugsSummaryTableControl1Row"));
        }

        public BaseApplicationPage Page {
            get {
                return ((BaseApplicationPage)base.Page);
            }
        }

    #endregion

    

    }
  

#endregion
    
  
}

  